【问题标题】:How to pass all state values to the child component如何将所有状态值传递给子组件
【发布时间】:2022-12-04 11:34:30
【问题描述】:

How to pass state values to the child component(CreateUser)

In CreateUser, I am trying to collect as props.data but getting \"undefined\"

const One = (props) => {
  const [info1, setInfo1] = useState({
    firstname: \"\",
    lastname: \"\",
    email: \"\",
    mobnumber: \"\",
    password: \"\",
  });
//....

  return (
    <div>
      <div className=\"container\">
        <div className=\"row \">
          <div className=\"col-4\">
            <CreateUser
              onInputChanged={onInputChanged}
              data={props.info1}
            ></CreateUser>
          </div>
          <div className=\"col\">
            <SelectParker />
            <br />
            <ActionButtons {...props} nextStep={validate} />
          </div>
        </div>
      </div>
    </div>
  );

// In CreateUser, I am trying to collect as props.data but getting \"undefined\"

  • You should use data={info1}. info1 is a state not props.
  • Yes, Its working @DecPK

标签: reactjs


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 2019-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-20
  • 2022-01-18
  • 2017-05-31
  • 2019-07-14
相关资源
最近更新 更多