https://github.com/geekeast/react-props-key
Reset children component state when some parts of parent components changes
https://github.com/geekeast/react-props-key
react-key
Last synced: 12 months ago
JSON representation
Reset children component state when some parts of parent components changes
- Host: GitHub
- URL: https://github.com/geekeast/react-props-key
- Owner: GeekEast
- Created: 2020-04-18T14:50:00.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-18T14:50:05.000Z (almost 6 years ago)
- Last Synced: 2025-03-02T12:17:27.953Z (12 months ago)
- Topics: react-key
- Language: HTML
- Homepage: https://codesandbox.io/s/github/GeekEast/react-props-key
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Needs
- Parent components pass default value of state into children component
- state management is handled by the children component ( uncontrolled )
- **when some parts of state in parent component changes, the children component can be `reset`**
### key
- simply `key=`
> When a key changes, React will create a `new component instance` rather than **update** the existing one.
```javascript
class EmailInput extends Component {
state = { email: this.props.defaultEmail };
handleChange = event => {
this.setState({ email: event.target.value });
};
render() {
return ;
}
}
;
```