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

[v6] Support custom meta props? #1634

Closed
smirea opened this issue Aug 26, 2016 · 2 comments
Closed

[v6] Support custom meta props? #1634

smirea opened this issue Aug 26, 2016 · 2 comments

Comments

@smirea
Copy link
Contributor

smirea commented Aug 26, 2016

Use-Case: apart from the existing flags (dirty, touched, ...) i'd like to implement my own custom state highlighted to globally highlight fields based on interaction.

I've tried using a separate highlighted: {} state in the form, but mimicking the tree anywhere else is clumsy. Changing the value of the input is also not ideal (aka from foo: String to foo: {value: String, highlighted: Bool}) since that requires changing the signature of the model, which, more often than not, is based on a database object

Ideally the interaction would be:

combineReducers: {
    form: form.plugin((state, action) => {
        if (action.type !== 'highlight') return state;
            return {
                    ...state,
                    fields: {
                        ...state.fields,
                        [action.meta.field]: {
                            ...state.fields[action.meta.field],
                            highlighted: action.value,
                        },
                    },
                };
    })
}

and in my component:

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

render = ({input, meta: {highlighted}}) => 
     <div style={highlighted ? 'fancy' : null}><input {...input} /></div>

but that's not available since the meta props are hand-picked and hardcoded.

TL; DR: what do you think of adding ...state on line https://github.com/erikras/redux-form/blob/master/src/createFieldProps.js#L68 to enable user defined meta props

@erikras
Copy link
Member

erikras commented Sep 15, 2016

Fix published in v6.0.3.

@lock
Copy link

lock bot commented Jun 2, 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 2, 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

No branches or pull requests

2 participants