首页 > 解决方案 > 在 next.js 打字稿中传递状态时,我不断收到:不可分配给类型“IntrinsicAttributes”

问题描述

我正在尝试将我的 react next.js typescript 应用程序中的状态从 index.tsx 页面传递到我的注册组件,但是我不断收到电子邮件 useState 挂钩上的错误:

键入'{电子邮件:字符串;}' 不可分配给类型“IntrinsicAttributes”。类型“IntrinsicAttributes”上不存在属性“电子邮件”。

我将如何解决这个问题,我的代码如下

export default function Home() {
  // state to handle signup email and password
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");

  return (
    <div className={styles.container}>
      <title>
        example
      </title>
      <div className={styles.container}>
      </div>
      <Signup email={email} /> //The error shows up here as I am passing the state
      <Login />
      <link rel="icon" href="/favicon.ico" />
    </div>
  );
}

标签: javascriptreactjstypescriptnext.js

解决方案


推荐阅读