这可以将Nav.Link创建为react-router-dom链接:
<Nav.Link as={Link} to='/'>link</Nav.Link>
但这是
const props = { as: { Link }, to: '/' }
return (
<Nav.Link {...props}>link</Nav.Link>
)
失败:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `ForwardRef`.
我的Nav.Link位于不依赖react-router的组件库中,我希望从主应用程序中传递“ as = {Link}”,而不必将该依赖关系强加到库中
答案 0 :(得分:0)
D'哦!想通了!
volatile atomic<T>