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

Implemented custom meta props. Fixes #1634 #1684

Merged
merged 1 commit into from Sep 15, 2016
Merged

Implemented custom meta props. Fixes #1634 #1684

merged 1 commit into from Sep 15, 2016

Conversation

smirea
Copy link
Contributor

@smirea smirea commented Sep 2, 2016

Ref: #1634

This allow creating own meta properties for fields via the reducer:

combineReducers({
    form: form.plugin((state, action) => {
        if (action.type !== 'redux-form/CHANGE') return state;
        return setIn(state, 'fields.' + action.meta.field + '.myCustomProp', true);
    })
});

results are passed to the meta object:

<Field name='foo' component={renderFancy} />

const renderFancy = ({input, meta: {myCustomProp}}) => 
    <input type="text" {...input} style={myCustomProp ? {color: 'red'} : null} />

@codecov-io
Copy link

codecov-io commented Sep 2, 2016

Current coverage is 100% (diff: 100%)

Merging #1684 into master will not change coverage

@@           master   #1684   diff @@
=====================================
  Files          52      52          
  Lines        1115    1115          
  Methods         0       0          
  Messages        0       0          
  Branches        0       0          
=====================================
  Hits         1115    1115          
  Misses          0       0          
  Partials        0       0          

Powered by Codecov. Last update 9186bd3...5b58aa5

@erikras
Copy link
Member

erikras commented Sep 15, 2016

I wonder if this should be documented somewhere. It seems like a pretty obscure "feature".

Good job implementing it, though!

@erikras erikras merged commit cb3abb5 into redux-form:master Sep 15, 2016
@erikras
Copy link
Member

erikras commented Sep 15, 2016

Published in v6.0.3.

@marcselman
Copy link

In the current redux-form version you can only write plugin for specific forms.
I use dynamic form names so I don't see how I can add a plugin to that.
Any other way I can access the main redux-form reducer or add custom meta properties any other way?

@lock
Copy link

lock bot commented Jun 1, 2018

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 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants