An open API service indexing awesome lists of open source software.

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

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 ;
}
}

;
```