V
V
Vlad Osadchyi2020-03-07 22:12:12
Functional programming
Vlad Osadchyi, 2020-03-07 22:12:12

If a functional component receives data from the server in useEffect(), will it be a pure function?

If a functional component receives data from the server in useEffect(), will it be considered a pure function? And why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
frontend queen, 2020-03-08
@VladOsadchyi

with the same input data (props or data received via api, for example), the rendering will not differ? will not. this means that fc will be considered a pure function, therefore it can be memoized (here it is worth mentioning that if the state is redefined in the component, then react will not pay attention to the memo wrapper and will still re-render)

A
abberati, 2020-03-08
@abberati

No, it will not. A functional component will only be a pure function if it renders props and does nothing else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question