向路由器(React)中的组件发送多个道具



我正在尝试发送道具,但它没有按我预期的方式工作。
在这种情况下,只有newDataCount被正确发送,而props={props}是未定义的。

const {newDataCount} = useContext(JobInfoContext);
return( <Switch>
<Route
exact
path={`${path}`}
render={(props) => (
<Check newDataCount={newDataCount} props={props} />
)}
/>
</Switch>);

并且在这种情况下只有{...props}被正确发送并且newDataCount未被定义。

const {newDataCount} = useContext(JobInfoContext);
return( <Switch>
<Route
exact
path={`${path}`}
render={(props) => (
<Check {...props} newDataCount={newDataCount} />
)}
/>
</Switch>);

如何发送两个道具?

嗨,你能试试这个吗。它将为您工作:-

const {newDataCount} = useContext(JobInfoContext);
return( <Switch>
<Route
exact
path={`${path}`}
component={(props) => (
<Check {...props} newDataCount={newDataCount} />
)}
/>
</Switch>);