我开始使用react-router,我发现我可以在 Link 组件中传递“props”,以便某些值可以传递到另一个组件。我正在使用的按钮内发送一个名为“值”的组件,但是在接收该参数的组件中显示一条错误消息,其中包含消息“对象可能为空或未定义”。
\n\n这是我的代码:
\n\n我发送数据的地方:
\n\n<Container placeholder>\n <Segment>\n <Form>\n <Form.Field>\n <label>Correo</label>\n <input placeholder=\'Ingresa tu correo\' name=\'nombre\' onChange={actualizarUser}/>\n </Form.Field>\n <Form.Field>\n <label>Contrase\xc3\xb1a</label>\n <input placeholder=\'Ingresa tu contrase\xc3\xb1a\' name=\'password\' onChange={actualizarUser}/>\n </Form.Field>\n\n <Link to={{ pathname:\'/init/home\', state:{ value: token } }}> // Here I\'m sending the props to the next component\n <Button type=\'submit\'>SubmitNuevo</Button>\n </Link>\n <Button type=\'submit\' onClick={sendInfo}>Prueba</Button>\n </Form>\n </Segment>\n </Container>\n
Run Code Online (Sandbox Code Playgroud)\n\n以及我接收 location.state 的组件
\n\nconst Logged: React.FC<{}> = () => {\n\nconst [open, setOpen] = useState(false); \nconst location = useLocation(); // Here I\'m …
Run Code Online (Sandbox Code Playgroud) 最近我使用 NextJS 在 React 中启动了一个项目。我了解到,在这个工具中,“页面”文件夹中的每个文件都是站点中的一条路径。但这让我想知道...是否有任何方法可以配置它,以便我可以在“页面”文件夹中包含多个文件,而在部署应用程序时不显示它们?如果是这样,我该怎么办?
提前致谢