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

Create a HOC to access form name of form in context #3246

Closed
danielrob opened this issue Jul 25, 2017 · 2 comments
Closed

Create a HOC to access form name of form in context #3246

danielrob opened this issue Jul 25, 2017 · 2 comments
Labels
c:context relating to context enhancement improvements in current API help wanted

Comments

@danielrob
Copy link
Collaborator

Feature request:

Composibility all the way, right? Well, currently there is no way to e.g. use getFormValues for an unknown form, which makes form components that want to fetch values from whichever form they're in the context in unsupported by the library.

What is the current behavior?

Solve this in user land:

import React from 'react'

export default Component =>
  class getFormContext extends React.Component {
    static contextTypes = {
      _reduxForm: React.PropTypes.object,
    }

    render() {
      const {
        form: nope, // eslint-disable-line no-unused-vars
        ...props
      } = this.props
      const { _reduxForm: { form } } = this.context

      return <Component {...props} form={form} />
    }
  }

What is the desired behavior?

import { withFormName } from 'redux-form'
//...
withFormName(Component)
//...
const Component = ({ form }) =>  console.log("you're in the context of form" , form)

Other information

#3242, this SO, may partially or fully solve #3182.
Dan Abramov says:
https://twitter.com/dan_abramov/status/749715530454622208

@danielrob
Copy link
Collaborator Author

Covered by #4038

@lock
Copy link

lock bot commented Jun 4, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c:context relating to context enhancement improvements in current API help wanted
Projects
None yet
Development

No branches or pull requests

2 participants