fix derived state

This commit is contained in:
SpikeHD
2022-06-03 17:57:26 -07:00
parent 1ac4fd5a63
commit 97b2f8a616
2 changed files with 6 additions and 6 deletions

View File

@@ -30,10 +30,6 @@ export default class TextInput extends React.Component<IProps, IState> {
}
}
static getDerivedStateFromProps(props: IProps, state: IState) {
return { value: props.value || '' }
}
async componentDidMount() {
if (this.props.initalValue) {
this.setState({
@@ -42,6 +38,10 @@ export default class TextInput extends React.Component<IProps, IState> {
}
}
static getDerivedStateFromProps(props: IProps, state: IState) {
return { value: props.value || state.value }
}
render() {
return (
<div className="TextInputWrapper" style={this.props.style || {}}>