question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 6 years ago
  • Reactions:24
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
tnrichcommented, Jul 11, 2017

@erikras @ooflorent I propose adding the ability to pass an initialValue prop to a given field that would do the same thing as the initialValues 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.

3reactions
rtymchykcommented, Oct 12, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found