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

pass context to mapPropsToFields #69

Merged
merged 2 commits into from Apr 20, 2017
Merged

pass context to mapPropsToFields #69

merged 2 commits into from Apr 20, 2017

Conversation

plandem
Copy link
Contributor

@plandem plandem commented Apr 7, 2017

Close: #68

@coveralls
Copy link

Coverage Status

Coverage increased (+6.5%) to 89.713% when pulling 02bc62d on plandem:patch-2 into e9e2359 on react-component:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+6.5%) to 89.713% when pulling 8ea02eb on plandem:patch-2 into e9e2359 on react-component:master.

@benjycui benjycui merged commit 05e89ad into react-component:master Apr 20, 2017
if (mapPropsToFields) {
this.fields = mapPropsToFields(nextProps);
this.fields = mapPropsToFields(nextProps, nextContext);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I make a mistake.

It seems that you cannot get any value from nextContext, for this HOC doesn't subscribe any value, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this PR in master branch.

Copy link
Contributor Author

@plandem plandem Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's same issue as with connect from redux, I suppose. You have to define contextTypes for wrapped component. E.g.:

this one will work

class A extends React.Component {...}

A = Form.create(mapper)(A);
A.contextTypes = {
}

export default A;

but this one will NOT work:

class A extends React.Component {...}

A.contextTypes = {
}

export default Form.create(mapper)(A);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use a HOC to convert context to props, and then pass it to form.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#69 (comment) this is not a solution, it is confusing.

benjycui added a commit that referenced this pull request Apr 20, 2017
@fancygeek
Copy link

any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants