链接工作正常,除非我在UserProfile页面中。当我在UserProfile页面上并尝试点击链接到另一个用户个人资料页面的链接时,该网址将会更改,但新的UserProfile将不会呈现。
这是我的app.js
。
<BrowserRouter>
<div>
<Header authenticated={this.state.authenticated} currentUserId={this.state.currentUserId}/>
<Switch>
<Route exact path="/homepage" render={(props) => {
return <HomePage authenticated={this.state.authenticated} {...props} />
}} />
<Route exact path="/login" render={(props) => {
return <Login setCurrentUser={this.setCurrentUser} setCurrentUserId = {this.setCurrentUserId} authenticated={this.state.authenticated} {...props} />
}} />
<Route exact path="/logout" component={Logout}/>
<Route exact path="/search" component={Search}/>
<Route exact path="/forum" component={Forum}/>
<Route path="/user/:id" component={UserProfile} currentUserId={this.state.currentUserId}/>
<Route path="/wip/:wipId" component={WIP} currentUserId={this.state.currentUserId}/>
<Route exact path="/submit_wip/:userId" render={(props) => {
return <NewWIPForm authenticated={this.state.authenticated} currentUserId={this.state.currentUserId} {...props} />
}} />
<Route exact path="/edit_profile" render={(props) => {
return <EditProfileForm authenticated={this.state.authenticated} currentUserId={this.state.currentUserId} {...props} />
}} />
<Route path="/edit_wip/:wipId" render={(props) => {
return <EditWIPForm authenticated={this.state.authenticated} currentUserId={this.state.currentUserId} {...props} />
}} />
<Route exact path="/submit_thread" render={(props) => {
return <NewThreadForm authenticated={this.state.authenticated} currentUserId={this.state.currentUserId} {...props} />
}} />
<Route path="/thread/:threadId" component={Thread} currentUserId={this.state.currentUserId}/>
</Switch>
{this.state.authenticated ? null : (<Redirect to="/login" />)}
</div>
</BrowserRouter>
&#13;
然后在UserProfile页面上,我将链接到其他UserProfiles,如下所示:
<Link to={"/user/" + review.reviewerId}>
<Image className="reviewer-avatar" src={review.reviewerAvatar} responsive />
<div className="reviewer-name">{review.reviewerName}</div>
</Link>
&#13;
如果您发现我的代码有其他问题,请随时指出。