Limenius / liform-react

Generate forms from JSON Schema to use with React (& redux-form)
https://limenius.github.io/liform-react/
MIT License
174 stars 40 forks source link

Liform doesn't work with react-redux 6.0 #54

Open t-works opened 5 years ago

t-works commented 5 years ago

In react-redux v6 passing the store directly as a prop to a connected component was removed.

When I try to use liform with "react-redux": "^6.0.0" I get the following error: Uncaught Error: Could not find "store" in either the context or props of "Connect(Form(BaseForm))". Either wrap the root component in a , or explicitly pass "store" as a prop to "Connect(Form(BaseForm))" I used https://github.com/Limenius/symfony-react-sandbox to test this. The error appears after changing react libraries to more recent versions and running yarn upgrade. This is what I used in package json: "dependencies": { "bootstrap-sass": "^3.3.7", "classnames": "^2.2.6", "jquery": "^3.3.1", "js-yaml": "^3.12.0", "jwt-decode": "^2.2.0", "liform-react": "^0.9.0", "react": "^16.6.3", "react-dom": "^16.6.3", "react-helmet": "^5.2.0", "react-on-rails": "^11.2.1", "react-redux": "^6.0.0", "react-router-dom": "^4.3.1", "redux": "^4.0.1", "redux-form": "^8.1.0", "redux-thunk": "^2.3.0" },

jav974 commented 5 years ago

Same problem ! Had to switch back to using :

"redux-form": "^7.4.2", "react-redux": "^5.1", "connected-react-router": "^5.0"

...

ReactRedux provides {({ store }) => {} }}</ReactReduxContext.Consumer>. Perhaps it should be wrapped arround the FinalForm in Liform ?

I tried to embed the Liform inside the above statement, but the error is thrown inside Liform itself.

simon6023 commented 5 years ago

Hi ! Still having the same problem, did anyone find a solution, beside switching back to an earlier version of redux-form/react-redux ?

tapetersen commented 5 years ago

Having the same problem I found out that the problem is not really liform-react not being compatible but rather that its dependencies are outdated and that causes 2 versions of react-redux to be installed if you have a newer installation specified in package.json (or some other package has as a dependency). I will probably submit a PR but until that is done and accepted the easier solution is to override the dependency-resolution in the top level project either by editing package.lock.json for npm or using https://yarnpkg.com/en/docs/selective-version-resolutions if you are using yarn.

In my case

  ...
  "resolutions": {
    "liform-react/redux-form": "8.2.0",
    "liform-react/react-redux": "7.0.3"
  }
...

in package.json solved it (only works if using yarn)