Next.js Discord

Discord Forum

react-day-picker [Error] Failed to load resource (style.css.map)

Answered
Plott Hound posted this in #help-forum
Open in Discord
Plott HoundOP
Hi i'm using https://react-day-picker.js.org/start in my next 14.0.4 app folder project and i'm getting an error every time a page re-renders that the style.css.map is not found.
import { DayPicker } from 'react-day-picker';
import 'react-day-picker/dist/style.css';

function Component() {
  return <DayPicker />;
}

it is in a client component and the css is loading fine and the component works perfectly but my console is spamming these errors.

should i be doing something special when importing the css?

I tested the lib in a fresh react vite ts and the error was not there.
Answered by Ray
I don't get error with fresh next project, how do you use it?
View full answer

88 Replies

Plott HoundOP
bump
Answer
@Ray I don't get error with fresh next project, how do you use it?
Plott HoundOP
thanks for taking a look. i just tried it in a fresh project and also didn't get the warning :thinq: so it must be an issue in my code. I'll go back to the drawing board and figure it out since its specific to my code. its a huge file at this point so i'll spare all the gory details but it boils down to this
'use client'
import { DayPicker } from 'react-day-picker';
import 'react-day-picker/dist/style.css';
import './DayPicker.css'; // custom styles, makes no difference if i remove them.

// Server actions and states 

  return (
    <DayPicker
      mode="single"
      selected={selectedDate}
      onSelect={handleDateSelect}
      footer={footer}
      showOutsideDays 
      fixedWeeks
      disabled={disabledDays}
    />
  )
i'll start from scratch and figure out what is triggering it
just wanted to check if it was a common issue of importing the css like so
import 'react-day-picker/dist/style.css';
also its not happening in prod
maybe try importing the style on the page
Plott HoundOP
lemme try that now
the actual error is
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (style.css.map, line 0)
it show the error on page load?
do you see a 404 request in the dev console?
Plott HoundOP
i tried it in the top level page.tsx of the page and get the same error.
the path its looking for is
http://localhost:3000/_next/static/css/app/(board-layout)/task/[id]/style.css.map which is clearly wrong
lol
let me try importing there
you have this path app/(board-layout)/task/[id]/page.tsx right?
Plott HoundOP
yeah thats the path that the date picker is running on
the style map is in node_modules/react-day-picker/dist/style.css.map
sorry if this is a really dumb question. i've not imported css in next like this before
in my code the import is import 'react-day-picker/dist/style.css';
which was just what the guide suggested
yes it is how next import css
Plott HoundOP
the css is loading fine and i can see its working. just a browser 404 for the style map in dev mode
I still don't get error
Plott HoundOP
ok clearly my code is shit. im gonna start over and stop wasting your time lol
what url are you visiting and you get that error?
/ or /task/[id]?
Plott HoundOP
http://localhost:3000/task/clrgnwoex00016y7zoamv9n4o
its in the dynamic route under task / [id]
which would correlate to the 404 from http://localhost:3000/_next/static/css/app/(board-layout)/task/[id]/style.css.map
did you try yours in a dynamic route and it worked?
have you tried with disable cache?
Plott HoundOP
lemme try
but the path of the styles is
Plott HoundOP
thanks for confirming. no difference with disable cache
do you import the style on global.css?
Plott HoundOP
my global.css is just
@tailwind base;
@tailwind components;
@tailwind utilities;
im importing the css in the page.tsx of the dynamic route
import 'react-day-picker/dist/style.css';
which is app/(board-layout)/task/[id]/page.tsx
rm -rf .next
Plott HoundOP
more like rm -rf / lol
lemme try
rm -rf .next may work but Im sure rm -rf / will not work lol
Plott HoundOP
nah that didnt do it. dude thank you so much for trying. there's clearly some bad code somewhere so im gonna start out fresh and see whats going on
its a massive app so hard to show you all the related code
oh well
you could try import the style in css
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "~react-day-picker/dist/style.css";
Plott HoundOP
i'll let you know if i figure it out. weird that i dont get it in prod, just dev considering its a 404
@Ray you could try import the style in css css @tailwind base; @tailwind components; @tailwind utilities; @import "~react-day-picker/dist/style.css";
Plott HoundOP
doing this and removing the other import gives:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (style.css.map, line 0)

404 on http://localhost:3000/_next/static/css/app/style.css.map
maybe rm -rf node_modules and install again
"react-day-picker": "^8.10.0", ?
Plott HoundOP
"react-day-picker": "^8.9.1",
and npm outdated shows no updates :/
👀
Plott HoundOP
updated it manually. now im on "react-day-picker": "^8.10.0", still getting the error lol
gonna try to setup a minimal repro and see whats going on
once again thank you so much for the help
do you have anything in next.config.js?
Plott HoundOP
also to clarify - if i remove this import 'react-day-picker/dist/style.css'; the 404 goes away so its definitely this import
/** @type {import('next').NextConfig} */
const nextConfig = {
    reactStrictMode: true,
    images: {
        remotePatterns: [
          {
            protocol: 'https',
            hostname: 'avatars.githubusercontent.com',
            port: '',
          },
          {
            protocol: 'https',
            hostname: 'images.unsplash.com',
            port: '',
          },
        ]
      }
}

module.exports = nextConfig

not really
try create a styles.css and import it
@Ray try create a styles.css and import it
Plott HoundOP
sorry can you clarify?
not sure what you meant
create a style.css on app/(board-layout)/task/[id]/style.css
and import it on the page
Plott HoundOP
1 sec
yeah it works and i get no errors.
import './style.css'
you see a request to page.css?v=xxxxx right?
Plott HoundOP
in the network tab like this?
i just put !important on to check it works. no judgement! lol
omg its only happening in safari 🤦‍♂️
ffs
lol
let me try on safari
I don't get error with safari
oh nm it does
Plott HoundOP
i remember havign the same thing using react-bootstrap years ago
it logged on the console but not on the network tab
Plott HoundOP
i guess i just have to ignore it, or dont import the css and build it myself
thanks for the help mate. that was a journey ha!
:feelsadman:
Plott HoundOP
i dont see any solution other than ignoring or rewriting the css. i'll leave an issue on the day picker repo
ngl glad i dont have some underlying borked code that was causing this
Cape lion
Hey @Plott Hound did you find any solution. I just wanted to try out react-day-picker but as ssoon as I add the css import import style from './day-picker.module.css'; I see a bunch of errors from my server.
Cape lion
Not realy related to pin point the issue. I use Next 14 app folder with trpc and as soon as I add the css import bunch of trpc call fail as Unauthenticated