【发布时间】:2022-01-18 16:57:30
【问题描述】:
当我把state值放在react router dom的link prop里面的时候,我想在被移动的组件中使用我在执行link时放在state里面的数据,但是不知道怎么用。
console.log(location;)的时候,我想看状态值中的wordlist。
<Link
to={{
pathname: `/test/${wordlist[0]?.contents}`,
state: {
wordlist: wordlist,
},
}}
>
<ColorButton>test</ColorButton>
</Link>
export default function Test(props) {
const location = useLocation();
console.log(location);
return()
}
【问题讨论】:
标签: javascript reactjs