我正试着在blocks...but中加入一些链接,这对我不起作用。我想这么做。

链接标记未重定向...
const Relacionados = props => {
const {items} = props;
const links = items.map((item, index) =>
<li key={index}><Link to={'/noticia-' + item.id}>{item.titulo}</Link></li>
)
return (
<div className={'related bg-secondary'}>
{items.length === 0 || <h4 className="text-white ml-3 intro">También podría interesarte...</h4>}
<ul>
{links}
</ul>
</div>
)
}未显示的部分如下:
<BrowserRouter>
{entity === null || <NavbarErma entity={entity}/>}
<Route exact path="/" component={HomePage2}/>
<Route path="/noticia-:id" component={LeerNoticia}/>
</BrowserRouter>发布于 2020-01-17 03:43:06
我发现了我自己。这解决了我的麻烦!
componentWillReceiveProps(nextProps) {
if(this.props.match.params.id !== nextProps.match.params.id) {
apiGET('/noticias/' + nextProps.match.params.id).then(items => {
this.updateState(items.data, 'noticia')
})
}
}https://stackoverflow.com/questions/59776386
复制相似问题