skratchdot / react-bootstrap-daterangepicker

A date/time picker for react (using bootstrap). This is a react wrapper around the bootstrap-daterangepicker project.
http://projects.skratchdot.com/react-bootstrap-daterangepicker/
Other
474 stars 203 forks source link

3.4.0 broke usage with multiple children nodes #146

Closed harmony7 closed 4 years ago

harmony7 commented 7 years ago

In 3.4.0 (specifically in https://github.com/skratchdot/react-bootstrap-daterangepicker/commit/7e0e2f7297f12eec90e69a32024065d1d3efbb8e) a change was made and now there is an assumption that the component will only have a single child node. This can break existing apps that have used more than one child node.

(It broke ours and caused React to throw Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. from inside react-dom, and it was very difficult to narrow down the cause to react-bootstrap-daterangepicker.)

If the change was intentional, then it's my opinion that you should:

  1. Bump to 4.x because the API surface has changed in a breaking way
  2. Also release a 3.4.1 that reverts this as not to break existing apps out there that rely on ^3.x

Or, if this had been the intended behavior all along, then

  1. Use React.children.only This would give more meaningful error message Uncaught Error: React.Children.only expected to receive a single React element child. that is thrown from inside the component's render method.
  2. Also update the docs to mention that this is a requirement
Strateus commented 7 years ago

How to fix this?

skratchdot commented 4 years ago

closing this due to inactivity. please re-open if this is still an issue in v6.0.0 or greater