react-facebook icon indicating copy to clipboard operation
react-facebook copied to clipboard

Subscribe without children gives error

Open cfenzo opened this issue 7 years ago • 3 comments

Using <Subscribe/> as in the example in the Readme gives the following error:

Error: Initialize(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

The above error occurred in the <Initialize> component: in Initialize (created by Context.Consumer) in LoginStatus in div (created by RootElement) in RootElement in r in Unknown in Facebook in Provider

This is caused by Subscription calling Initialize without a children prop, and Initialize rendering children without checking if it exists (it should be required for Initialize, no?).

Could be fixed by either having Initialize return children || null or changing Subscribe to call Initialize with children set to null as default. I'd be happy to provide a PR, but let me know which solution is preferred (my vote is on the latter..)

cfenzo avatar Dec 07 '18 11:12 cfenzo

thanks I will check it

seeden avatar Dec 12 '18 20:12 seeden

any update or how to work-around this?

marcellobarile avatar Jan 26 '19 16:01 marcellobarile

You could have an empty array as children for the Subscribe component: <Subscribe event="some_event" onChange={handleChange} children={[]} />

martin-arusalu avatar Jun 05 '20 13:06 martin-arusalu