Pass props to another component onclick of a button

后端 未结 2 1612
终归单人心
终归单人心 2021-01-15 09:55

In my nextJS app, I want to pass props of one component to another which is neither a parent nor child of first component.How can I do that?

There is a Order

2条回答
  •  旧巷少年郎
    2021-01-15 10:53

    So, reasoning is:

    1. you have some parent component/screen. Lets call it OrdersPage
    2. within OrdersPage you have 2 components: Order and OrdersViewer
    3. what you are interested in, within context of parent components (OrdersPage) is to know which order was clicked and show that in other child
    4. obviously, you need state on your OrdersPage component
    5. when you click some order, you will put it in state
    6. your other component will receive state as props and show clicked component

提交回复
热议问题