React 'props' 未定义

React 'props' is not defined

有人能告诉我为什么没有定义 props 吗?在这段代码中,我需要通过这种方式调用另一个组件,

看看

我是 React 新手,有人可以帮我吗??

下面的 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>

这一行

<SC.ButtonPlus onClick={() => props.setNewContact(true)}>

应该

<SC.ButtonPlus onClick={() => this.setNewContact(true)}>

问题是您正在访问 props 上的方法

                              /* change this  */
 <SC.ButtonPlus onClick={() => this.setNewContact(true)}>
    <GoPlus size="24px" color="#FFF" />
  </SC.ButtonPlus>

希望对您有所帮助!