A
A
Artyom2020-04-16 09:31:20
React
Artyom, 2020-04-16 09:31:20

Is it worth using react context everywhere where the nesting is more than 1 element?

Is it possible to use context always when nesting is greater than 1? Because passing props even when nesting 2-3 elements seems irrational. How do they usually do it in reality?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2020-04-16
@danyvasnafig

In reality, redux is most often shoved.
The use of the Context API, according to the React architect, is most often unreasonable. https://twitter.com/sebmarkbage/status/12198364319...
https://twitter.com/sebmarkbage/status/12198289982...
Ideally, there should be a composition where render props can be applied.
That is, each page is loaded via lazy, and contains a JSX canvas that can communicate through render props, and the page component will store most of the state.
In general, no one forbids using Context for nesting >=2, however, local state does the job quite well if the components are broken up normally.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question