【发布时间】:2020-10-16 05:25:12
【问题描述】:
有人能告诉我为什么没有定义 props 吗?在这段代码中,我需要通过这种方式调用另一个组件,
看看
我是 react 新手,谁能帮帮我?
反应代码如下:
class ViewNotas extends Component {
constructor(props) {
super(props);
this.state = {
open: [],
newContact: false,
edit: [],
loading: false,
};
this.handleOpen = this.handleOpen.bind(this);
this.setNewContact = this.setNewContact.bind(this);
}
setNewContact(set) {
this.setState({
newContact: set,
});
}
handleOpen(id, isOpen) {
if (!isOpen) {
this.setState({ open: this.state.open.concat(id) });
} else {
this.setState({
open: this.state.open.filter((objectId) => id !== objectId),
});
}
}
render() {
let data = this.props.data;
return (
<Modal open={this.props.open} visible={this.props.visible}>
<SC.Container>
<SC.Header>
<SC.Title>Notas</SC.Title>
<SC.ButtonPlus onClick={() => props.setNewContact(true)}>
<GoPlus size="24px" color="#FFF" />
</SC.ButtonPlus>
【问题讨论】:
标签: reactjs components react-props