C
C
copal2015-01-02 17:46:41
React
copal, 2015-01-02 17:46:41

Can stores store components?

I ask the question not in the context of flux or redux, but in the context of the React ideology itself.
Can a store store components? I have a PagesContainer component that, when changing path, removes one page and adds another. Where should these pages be located? Lie in the store?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman_Kh, 2015-01-02
@Roman_Kh

Since a component is a JavaScript object, technically it can be stored in a store.
But you shouldn't do this, because React components have a very specific life cycle, which does not include the "component lying around in the store" state. Components can be easily created and deleted on the fly as needed.
If desired, you can store any data necessary to create your components in the store.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question