I am trying to make a profile page with react router and Warning: Unknown prop params on <a> tag. Remove this prop from the element.
I am trying to pass params to a route so each user has their own unique page loaded with their content. The solution I got was from 2015 and I don't know if they had removed it. Is there a new/updated version of passing params into the path of a route or am I doing something wrong?
<Route component={userProfile} path="/user/:userId" userIdentity={Meteor.userId()}/>
<p><Link to="/userProfile/:userId" params={{userId: Meteor.userId()}}>My Profile</Link></p>
答案 0 :(得分:0)
您是否只是想将userId
作为参数传递?您可以通过调用<UserProfile />
并从那里开始,在您的链接组件this.props.match.params.userId
中访问它。
答案 1 :(得分:0)
你想这样做
<Link to={`user/${Meteor.userId()}`} />
即。使用用户标识构建要链接到的静态路由。没有比这更复杂的了。