我不断收到此错误
implementation "androidx.core:core:1.5.0-alpha04"
即使抛出此错误,该代码似乎仍然可以工作。例如,当我将setState与textInput组件一起使用时,就会发生这种情况-
Warning: Cannot update a component from inside the function body of a different component.
和
return (
<View style={styles.container}>
<View style={styles.inputContainer}>
<View style={styles.textInputContainer}>
<Text>Title of project:</Text>
<TextInput
editable={true}
placeholder="Type here"
value={this.state.title}
style={styles.textInput}
onChangeText={this.handleTitle}
></TextInput>
答案 0 :(得分:0)
如果使用箭头函数,请勿在构造函数中绑定函数。
Sheet2
或者您可以使用内联函数
class CreateProject extends React.Component {
constructor(props) {
super(props);
this.state = { title: "", dueDate: "", visibility: false };
}
handleTitle = (text) => {
this.setState({ title: text });
};
答案 1 :(得分:0)
您的代码似乎可以正常工作,请参见snack