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

setDefaultValues still renders without default #10

Closed
jhsu opened this issue Jul 18, 2016 · 3 comments
Closed

setDefaultValues still renders without default #10

jhsu opened this issue Jul 18, 2016 · 3 comments

Comments

@jhsu
Copy link
Contributor

jhsu commented Jul 18, 2016

since setDefaultValues calls setState inside Formous, the form component that is wrapped by Formous can still rendered once without default values

ie in the form's componentWillMount

componentWillMount() {
this.props.setDefaultValues({
    someField: 'hello'
  });
},
render() {
  this.props.fields.someField.value; // this will still be an empty string: ""
 // ...
}

it would be nice if the field options allowed an initial value or do you have another idea how render could be prevented until i am able to set the default value?

@ffxsam
Copy link
Owner

ffxsam commented Jul 18, 2016

Well, upon initial rendering, you're right, the field values would be empty. But a second render is performed when the values are populated, and then the fields are filled. If you put together a test project, you'll see that it works ok and all the fields are properly filled with defaults.

If you find that's not the case or there's some other issue, let me know!

@jhsu
Copy link
Contributor Author

jhsu commented Jul 19, 2016

i guess the problem is that it still causes a render with an empty string value which requires all components that take a value to accept and still render when an empty string value is given.

this is a problem in cases such as a dropdown select where a component might expect a valid value (a value that is an option)

@ffxsam
Copy link
Owner

ffxsam commented Jul 19, 2016

Dropdowns aren't supported just yet. Getting there!

If setDefaultValues is not working the way you expect, could you put together a reproduction of the problem you're experiencing? That way I can run it myself and take a look at what's going on.

Thanks!

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

No branches or pull requests

2 participants