reactjs - React. Is it bad if presentational components contain container components? -


according https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0#.i63w9pvzw

presentational components:

  • may contain both presentational , container components** inside, , have dom markup , styles of own.
  • have no dependencies on rest of app, such flux actions or stores.

i think if presentational components contain container components, depend on flux or redux (or whatever container components depend on).

that make presentational components hard test , reuse.

it's not bad, it's fine. whole point of react-redux let connect container components directly store without having pass entire store down every component prop. component reuse isn't issue, since <provider> component make connected container components work anywhere below it.

it's not hard test container components either. can make connected component default export, export unconnected component named export, can use tests, , manually pass props in tests. see "connected components" section of 'writing tests' part of redux docs more info.

as testing presentational components contain container components, won't problem. shallow render still work fine in tests (unless you're running this issue). , if need mount component in test, can wrap in <provider> component store specific test.

edit: answer specific redux react-redux. other flux implementations may have difficulties i'm not aware of.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -