mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 15:44:35 +01:00
fix derived state
This commit is contained in:
@@ -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() {
|
async componentDidMount() {
|
||||||
if (this.props.initalValue) {
|
if (this.props.initalValue) {
|
||||||
this.setState({
|
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() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="TextInputWrapper" style={this.props.style || {}}>
|
<div className="TextInputWrapper" style={this.props.style || {}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user