React-big-calendar: Version 0.12.0 does not support custom component for events in month-view anymore?

Created on 10 Jan 2017  路  5Comments  路  Source: jquense/react-big-calendar

Hi there,

I was using calendar version 0.11.1 until today which worked fine. After updating to 0.12.0 (because of #201) the calendar seems not support a custom component for components.event anymore.

This only happens in the month-view (week and day seem to work just fine)

Basically i'm doing this:

import Entry from '../Entry';
[..snip..]
<BigCalendar
    [..snip..]
    views={['month', 'week', 'day']}
    components={{
        event: Entry,
    }}
/>

What still works is passing a custom component for the toolbar.

bug

Most helpful comment

You can pass custom props via a closure, since functions are acceptable Components

renderEvent = (eventProps) => {
  return <MyEvent {...eventProps} custom={this.props.custom} />
}

render() {
  return (
    <BigCalendar components={{ event: this.renderEvent }} />
  )
}

All 5 comments

not intentional, sounds like a bug!

@HerrZatacke Would you mind sharing (at least generally) what your custom event component looks like? I cannot find documentation or an example anywhere.

Update: I ended up figuring it out via this StackOverflow question. (Might be worth putting something similar in the docs).

However, what remains unclear to me is how to pass custom props to our custom components. The BigCalendar component itself renders these child components.

You can pass custom props via a closure, since functions are acceptable Components

renderEvent = (eventProps) => {
  return <MyEvent {...eventProps} custom={this.props.custom} />
}

render() {
  return (
    <BigCalendar components={{ event: this.renderEvent }} />
  )
}

@jquense Absolutely brilliant, cheers. Took me way too long to figure that one out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolasriccardi picture nicolasriccardi  路  3Comments

jgautsch picture jgautsch  路  3Comments

martinnov92 picture martinnov92  路  3Comments

tiaaaa123 picture tiaaaa123  路  4Comments

KatiaPosPago picture KatiaPosPago  路  3Comments