【发布时间】:2018-03-07 13:20:19
【问题描述】:
我正在创建一个内部布局。我正在从另一个场景进入这个场景。因此,在开始时会呈现另一个布局。在我进入第二个场景(带有 TextInput 标签)后,我收到警告,例如:
componentWillMount 已弃用,将在下一个版本中删除 主要版本。请改用 componentDidMount。作为临时 解决方法,您可以重命名为 UNSAFE_componentWillMount。请更新 以下组件:App、Container、Image、Text
这很奇怪,因为我没有使用componentWillMount方法,所以我猜它是隐式调用的。
这是组件的代码
class MainTopBarAfterSearch extends Component {
constructor() {
super();
this.state = { text: " " };
}
render() {
const { topBarContainer, imageStyle, textInputStyle } = styles;
return (
<View style={topBarContainer}>
<TouchableOpacity onPress={() => Actions.menu()}>
<Image
source={require("../../../resources/menuWhite.png")}
/>
</TouchableOpacity>
<TextInput
style={textInputStyle}
placeholder="Begin to search"
value={this.state.text}
onChangeText={text => this.setState({ text })}
/>
<Image source={require("../../../resources/filter.png")} />
</View>
);
}
}
【问题讨论】:
-
你用的是哪个版本的 react?
-
"react": "^16.3.0-alpha.1", "react-native": "0.54.0",
-
Here 看看这个
标签: reactjs react-native react-native-router-flux