我对reactjs/nextjs很陌生,在如何将值从一个页面传递到另一个页面时,我需要一些帮助。
我想将"Apply.jsx“页面中的值传递给confirmation.jsx页面。值为"name=joe“
Apply.jsx
Router.push({
pathname: "/jobseeker/confirmation" })
confirmation.jsx.(需要在此函数中获得值)
const Confirmation = props => {
const { children, classes, view, ...rest } = props;
return (
<div className="cd-section" {...rest}>
<CardWithoutImg bold view="Seeker" link="confirm" orientation="left" />
</div>
);
};
export default withStyles(blogsStyle)(Confirmation);
发布于 2020-07-05 10:48:29
您可以将其作为查询传递。
const handler = () => {
Router.push({
pathname: '/jobseeker/confirmation',
query: { name: 'joe' },
})
}
在Confirmation
中,您可以使用useRouter
钩子检索它
const Confirmation = props => {
const router = useRouter();
console.log(router.query) // { name : 'joe' }
const { children, classes, view, ...rest } = props;
....
};
https://stackoverflow.com/questions/62744211
复制