你应该如何传递带有Redirect
组件的props ,而不让它们expose 在url中?
像这个<Redirect to="/order?id=123 />"
?我用的是react-router-dom
.
你应该如何传递带有Redirect
组件的props ,而不让它们expose 在url中?
像这个<Redirect to="/order?id=123 />"
?我用的是react-router-dom
.
你应该先在应用程序中定义的路由中传递props .js
<Route path="/test/new" render={(props) => <NewTestComp {...props}/>}/>
然后在第一个组件中
<Redirect
to={{
pathname: "/test/new",
state: { property_id: property_id }
}}
/>
然后在重定向的NewTestComp中,你可以像这样在任何地方使用它
componentDidMount(props){
console.log("property_id",this.props.location.state.property_id);}