Discussion icon indicating copy to clipboard operation
Discussion copied to clipboard

Dynamic Component Instantiation

Open falecci opened this issue 8 years ago • 1 comments

Hi,

I have the following scenario. I have a list of categories. Whenever I click one, I make an ajax request to get its subcategories. After that, I should render another list with the subcategories, which then, of course, can have subcategories.

This could led up to something like this:

Electronics -> Computers -> Notebooks -> HP -> Accessories.

The only way I can imagine of doing this, is creating a component for the list of items, and creating a new instance whenever I click one category and have subcategories.

Is there any other way of doing it? if not, how could I create a new instance of a component everytime after I make a request?

Thanks!

falecci avatar Jun 26 '17 17:06 falecci

Well use render function and recursion. basically you have component that renders list which list items can be clicked. so render recursively the same component which component structure is based on nested object.

FluksikartoN avatar Jan 17 '18 14:01 FluksikartoN