Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Bind ManagedFormInput props to input props #40

Conversation

@asantos00
Copy link

@asantos00 asantos00 commented May 22, 2017

Hi! At first good job with this library :)

I wanted to bind defaultValue value to input and I couldn't, that's why I'm doing this fix :)

I hope that this can be merged 👍

Copy link
Owner

Hello, thanks for the kind words and the PR!

The FormInput component in Framework7 React (which ends up rendering a ManagedFormInput) is designed to work as a controlled form component. defaultValue is only meant for uncontrolled components as far as I know--you set the default value and and then updates to the element don't affect state and are read by accessing the DOM element (e.g., via refs). Additionally, defaultValue is not a supported prop on the FormInput component, so there is no way that defaultValue should be getting passed into the ManagedFormInput component.

The preferred way to set an initial value in Framework7 React is by setting the value prop on the initial render and provide an onChange handler, as shown in the kitchen sink. The combination of setting the value prop and providing an onChange makes it a controlled component.

Alternatively, if you strongly prefer to use an unmanaged input component, you can certainly render your own input element instead of F7 React's FormInput component.

Or perhaps I am misunderstanding something?

renatoholanda reacted with thumbs up emoji

Copy link
Author

Hi @bencompton, you are completely right, I certainly used this wrong, the first time I tried, and I was not binding the value correctly, but thanks for the explanation and sorry to bother!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /