C
C
connecter2019-10-09 14:44:17
React
connecter, 2019-10-09 14:44:17

Passing props to nextjs?

How to pass props to a component that is rendered when passing through next/link?
The LinkUrl component to which I pass the name via props

const LinkUrl = props => {
    return (
        <li>
            <Link href={`/post/[title]`} as={`/post/${props.title}`}>
                <span>
                    {props.title}
                </span>
            </Link>
        </li>
    )
}

The same component that is rendered when clicking on the link and which needs to be passed props (not via getInitialProps)
const qwe = props => {
    const router = useRouter();
    return (
        <div>
            <MyLayout>
                <span>
                    
                </span>
            </MyLayout>
        </div>
    )
}

Tried a variant, by type
<Link href={`/post/[title]`} as={`/post/${props.title}`} data={"props data"}>

But this option doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vadimMalovaniy, 2019-10-09
@connecter

No way. Is it only through the query parameters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question