Easier default/initial values
See original GitHub issue@erikras
I really wish there was a simpler way of setting up initial values at the Field level in redux form. Currently, the only way to set initial values, by passing an initialValues prop into the reduxForm component, often seems overly verbose and complicated. I find myself duplicating logic and having hardcoded field names spread around multiple files instead of just setting the initial value at the <Field/>
level.
I know that the <Field defaultValue={XXXX}/>
was taken out to somewhat recently to “reduce confusion”, but is there actually any technical reason why default/initial values can’t be defined at the field level?
Thank you!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:24
- Comments:9 (3 by maintainers)
Top Results From Across the Web
2.6 Default initial values
Default initial values cannot be given to the predefined types but they can be given to types derived from them such as the...
Read more >Initial value - CSS: Cascading Style Sheets - MDN Web Docs
The initial value of a CSS property is its default value, as listed in its definition table in the specification. The usage of...
Read more >3 Ways to Set Default Value in JavaScript | SamanthaMing.com
Let's break down the 3 different ways to set Default Values using logical operator, ternary, and if/else...
Read more >What is a Java String's default initial value? - Stack Overflow
I know that for int variables, the default value is assigned as 0 , as the instances are being created. But what becomes...
Read more >Is it better approach to handle default (initial) values of ...
Than we create two Int assets, one variable with default value and another one with changeable value. Finally I have problems about accessor ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@erikras @ooflorent I propose adding the ability to pass an
initialValue
prop to a given field that would do the same thing as theinitialValues
prop to the entire form, but for the single field. The<Field/>
's initialValue prop would take precedence over the form’s initialValues prop.Unlike initialValues, the initialValue prop would only be “additive”. By that I mean it wouldn’t affect the initialValue of any other Fields within the same form.
In a similar, but slightly unrelated vein, I think that we should also add a similar concept of a validate prop at the field level, but I can open a new thread for that.
The current setup is especially frustrating with a wizard. I would like to be able to set the initial values of a field on a certain step of a wizard, but doing this wipes all the data accumulated up till that step. So I am forced to use
initialValues
on the first step of the wizard, which doesn’t even work if I need that to depend on data from another step.