Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider.render(): A valid React element (or null) must be returned. #1521

Closed
bittermanq opened this issue Oct 18, 2018 · 16 comments
Closed
Labels

Comments

@bittermanq
Copy link

bittermanq commented Oct 18, 2018

Hello,
after updating of the react-datepicker to v 1.7.0 I started getting a following error in console during a rendering:

Uncaught Error: Provider.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

I found that v 1.6.0 still works well, and this error appears in index.js, line: 2556 (PopperComponent.render()), where Manager from react-popper package is created. Maybe it is related somehow to commit "Upgrade react-popper (#1483)". Cannot investigate it deeply.

@sammusic27
Copy link

the same for me.

@arran549
Copy link

same - I rolled back to version 1.4.1 (current Latest) and it's working

@allanserra1612
Copy link

allanserra1612 commented Oct 19, 2018

Even though I was returning the version to 1.4.1, it had not worked, I updated the react and react-dom to version 16.0.0 and it worked

I left the react-datepicker version as 1.4.1

@AlinaCapotaSG
Copy link

I have the same problem.

@briangleeson
Copy link

Run into the same issue as well when 1.7.0 was automatically picked up in our build pipeline. Rolling back to 1.6.0 works fine.

Based on the discussion above, could it be related to this commit that was merged after 1.6.0? Perhaps the Manager from react-popper can be undefined in some circumstances leading to the error from the OP

@ndinhphi
Copy link

ndinhphi commented Nov 7, 2018

The same for me. My version is 1.6.0

@sizeight
Copy link

Same here, up to version 1.6.0 works.

@martijnrusschen
Copy link
Member

I tried reproducing this with the examples site, but was unable to reproduce the error. Does someone have some steps to reproduce, or is it under specific circumstances?

@sizeight
Copy link

I use react-datepicker and reactstrap in my project. Both have react-popper as a dependency. In react-datepicker v1.7.0 the react-popper depencency was upgraded from ^0.9.1 to ^1.0.2. This is the update that broke for me.
reacstrap has dependency for react-popper of ^0.10.4

It seems the conflicting dependencies on react-popper major versions causes problems.

There is an outstanding issue to get reactstrap compliant with react-popper 1.0.x and it mentions that using packages with dependencies on different versions of react-popper together causes confusing errors.
See -> reactstrap/reactstrap#1197 (comment)

@sizeight
Copy link

Problem solved. This could be the cause of issue for others as well?

It boils down to webpack configuration.

The issue I experienced related to a react-popper dependency conflict

I use react-datepicker and reactstrap in my project, both depend on differing versions of react-popper. react-datepicker upgraded its react-popper dependency in the 1.6.0 -> 1.7.0 release. This caused my code to break. The reason has to do with reactstrap depending on react-popper 0.10.4 and react-datepicker now depending on a new react-popper major release 1.x.x.

Why would their differing dependencies cause a crash, isn't NPM supposed to manage conflicts like this? Yes, but the issue is in my webpack config.

webpack.config.js

...
modules: [
  path.join(__dirname, '../node_modules')
]
...

This forces all modules to resolve from the root node_modules, causing reactstrap to reslove the wrong react-popper.

Change webpack.config.js to:

modules: [
  'node_modules'
]

This resolves node_modules hierarchically, ensuring react-datepicker and reactstrap each resolve to the correct dependency of react-popper.

Got the clue here -> webpack/webpack#6505 (comment)

@lakesare
Copy link

Having the same issue, @sizeight's solution didn't help me. And I don't have any popper.js-s conflicting.

@lakesare
Copy link

lakesare commented Nov 21, 2018

I believe it's not working for us because our React is < 16.0.2.
Popper's document says

Using React <=15 or Preact? The components created with them don't support to return fragments, this means that you will need to wrap <Reference> and <Popper> into a <div> to make react-popper work.

Whereas they probably meant to say <=16, because that's when Fragment support is added to React (https://reactjs.org/blog/2017/09/26/react-v16.0.html).

Here is a relevant react-popper issue: floating-ui/react-popper#183, and their codesandbox: https://codesandbox.io/s/zr96k9j483 which creates exactly the same error as we see.

@vladbalan
Copy link

React 15.6.1 - rolling back react-datepicker to 1.4.1 fixed this for me (1.8, 1.6 did not).

@shlaikov
Copy link

shlaikov commented Mar 9, 2019

The same bug.
"react": "16.8.4", "react-dom": "16.8.4", "react-datepicker": "2.1.0"

@robertfwest
Copy link

robertfwest commented Apr 11, 2019

@lakesare hit the nail on the head. However, you don't have to upgrade React just for this. Instead, you can patch the package to have a div around the Reference and Popper. See https://www.npmjs.com/package/patch-package for how to do it. The patch I created against react-datepicker 1.8.0 is here:
react-datepicker+1.8.0.zip

@stale
Copy link

stale bot commented Oct 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 8, 2019
@stale stale bot closed this as completed Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests