简体   繁体   中英

react-big-calendar import failing for css

I have the react big calendar working but the css import is failing. The documentation says:

Styles can be found at: react-big-calendar/lib/css/react-big-calendar.css, and should be included on the page with the calendar component.

I've seen it imported w/ BigCalendar in other examples but it doesn't seem to be working for me.

import '/react-big-calendar/lib/css/react-big-calendar.css';
import BigCalendar from 'react-big-calendar';
import moment from 'moment';
import Month from './Month';
import React from 'react';
import Showfeed from './Showfeed';

How do I do this? Thanks!

Don't know what exactly problem you are facing. But To include css,you can try this. Not tested, but it should work.

require('react-big-calendar/lib/css/react-big-calendar.css');
  1. If above not works, copy the react-big-calendar.css file CSS and paste to your own css file.

I found the solution. Just needed to add this to my brunch-config.js file.

npm: {
  styles: {
  'react-big-calendar': ['lib/css/react-big-calendar.css']
  }
},

If your using this solution you can delete the import. You don't need it.

For anyone who stumbles on this issue:

OP is actually quite close. The import line has an additional slash at the front. If you're importing react-big-calendar as a node module the line here:

import '/react-big-calendar/lib/css/react-big-calendar.css';

Should be:

import 'react-big-calendar/lib/css/react-big-calendar.css';

这适合我

import '!style-loader!css-loader!react-big-calendar/lib/css/react-big-calendar.css';

try to add this CDN to your-react-project-root/public/index.html

<link href="https://cdn.jsdelivr.net/npm/react-big-calendar@0.19.0/lib/css/react-big-calendar.css" rel="stylesheet"/>

This worked for me

Try this:

import '../lib/css/react-big-calendar.css'

but first validate that the file exst in the path/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM