redux-form: Error: formValues() must be used inside a React tree decorated with reduxForm()

Bug report

Demo: https://stackblitz.com/edit/redux-form8?file=Form.js But demo doesn’t work because of https://github.com/erikras/redux-form/issues/4293

Steps to reproduce

$ npx create-react-app form
$ cd form
$ yarn add redux redux-form react-redux
# Copy code from demo index.js and Form.js
$ yarn start

So, about bug:

import { reduxForm, formValues } from 'redux-form';
/* ... */
export default reduxForm({ form: 'Form' })(formValues('name')(Form));

After update to version 8.0.1 using formValues decorator results in an error:

Uncaught Error: formValues() must be used inside a React tree decorated with reduxForm()

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 17
  • Comments: 24 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Any news on this issue?

@erikras will this be fixed any time soon?

Any ETA for this issue?

It looks like the component tree is inverted?

Hoc (created via withReduxForm) -> Context.Consumer -> ReduxForm -> Connect -> Form -> Context.Provider

The consumer is higher up the tree than the provider, and thus only ever receives the initial value (null, which causes the check to fail).

You can probably just refactor the rendering here? https://github.com/erikras/redux-form/blob/5cdfa2b8227edddc00ae079f767aa17b64d46526/src/createReduxForm.js#L1151

Hi guys. Any updates from a redux-form team?

Here is a version of that using recompose’s toRenderProps and fromRenderProps that allows the same usage as before.

Edit Redux Form - Simple Example

This is very strange. I wonder if it’s a bug in React?

Confirmed. Will investigate tomorrow.

The issue still exists in 8.0.4, working (broken) example: https://codesandbox.io/s/21m68rvozn

Published in v8.2.5.