Search code examples
javascriptreactjsreact-big-calendar

React big calendar has no default export


I wanted to use react-big-calendar, I installed the package with npm (version 0.28.0), but I was able to use the component because there is apparently no default export. The exact error is

Attempted import error: 'react-big-calendar' does not contain a default export (imported as 'BigCalendar').

If I should not use default export, I did not find anywhere what I should import instead. I used this tutorial in order to make it work. I searched on the internet for similar issue, but I did not find anything that provide a solution. My code so far is very minimalist, since I was not able to start anything

import BigCalendar from 'react-big-calendar'
import moment from 'moment'

const MyComponent = props => {
  const localizer = BigCalendar.momentLocalizer(moment)
  return(
    <div>
      <BigCalendar localizer={localizer}/>
    <div>
  )
}

Thank you in advance for any response.


Solution

  • I will suggest you to try this out.

    // the imports
    import { Calendar, momentLocalizer  } from 'react-big-calendar' 
    import 'react-big-calendar/lib/css/react-big-calendar.css';
    import moment from 'moment'
    const localizer = momentLocalizer(moment)
    
    // The component you should use instead the one you mentioned.
     <Calendar localizer={localizer} />
    

    let me know if that works for you, I remember having the same issue and I solved by doing this.

    Best regards, I hope it helps!