rcdexta / react-event-timeline

A responsive event timeline in React.js
https://rcdexta.com/react-event-timeline
MIT License
536 stars 56 forks source link

Crash when Timeline gets null as a child. #37

Open UjinT34 opened 5 years ago

UjinT34 commented 5 years ago

React.cloneElement(...): The argument must be a React element, but you passed null. The above error occurred in the component: in Timeline (created by TimelineComponent)

https://github.com/rcdexta/react-event-timeline/blob/master/components/Timeline.js#L8 https://stackoverflow.com/questions/55327901/react-treats-timeline-element-as-null-even-with-a-condition-check/55328070#55328070

vladejs commented 5 years ago

Something similar happens to me when logging out on my app:

TypeError: Cannot read property 'props' of null
    at Object.ReactElement.js.m.cloneElement (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at eval (/node_modules/react-event-timeline/dist/Timeline.js:1)
    at u (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at o (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at o (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at i (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at c (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at Object.l [as map] (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)
    at t.e (/node_modules/react-event-timeline/dist/Timeline.js:1)
    at h._renderValidatedComponentWithoutOwnerOrContext (44c44d30d32601e20aa98f13c405a7f1b9076b49.js?meteor_js_resource=true:17)

Is there a workaround?

howdyhyber commented 5 years ago

I also experienced this bug. Is there any solution to this?

howdyhyber commented 5 years ago

I sort of solved it.

When the value is null, pass an empty div and everything will be fine.