Mui-dataTables:通过单击“行:显示数据为null

问题描述 投票:0回答:1

将数据传递到另一页:

,我可以在console

中看到数据

const handleRowClick = (rowData, rowMeta) => { navigate("/history", rowData[0]); console.log(rowData[0], "products"); }; const options = { filter: true, selectableRows: "none", responsive: "simple", onRowClick: handleRowClick, };

历史页面:
state

中什么都没有 const History = (props) => { const { state } = useLocation(); //document ID here console.log(state, "state"); return ( <div> </div> ); }; export default History;

app.js

<Route path="/history" element={ <PrivateRoute> <Layout> <History /> </Layout> </PrivateRoute> } /> 我不知道这里有什么问题

函数最多占两个参数,即带有

edit-page

edit
键的“ torge和一个“选项”对象。

usenavigate
javascript reactjs material-ui react-router-dom mui-datatable
1个回答
1
投票

navigate
state
数组元素移到

replace

键下的选项对象中。 示例:

declare function useNavigate(): NavigateFunction; interface NavigateFunction { ( to: To, options?: { replace?: boolean; state?: any } // <-- options object, state ): void; (delta: number): void; }
使用接收组件上的
rowData
挂钩访问路线状态。

state

    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.