E
E
embiid2020-09-05 23:05:38
React
embiid, 2020-09-05 23:05:38

How to make dependency of one component to another?

For example, there is a block in which there are goods. When you click the "show more" button -> even more products are displayed on the page.

For example, there is a Block component where there are two react components inside it.
For example, Listitems -> products. A Button is a button that should show even more products when you click on it.

<Block
             <ListItems />

             <Button label="Show more"
                     className="red-background"
             />
      </Block>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-09-05
@embiid

The array of data to be displayed is passed to the ItemsList from the parent component, and the click handler is passed to the button from the parent component, in which the number of items passed to the ItemsList increases.
https://jsfiddle.net/oLce047k/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question