A
A
Artur Kudashev2019-08-15 12:59:49
React
Artur Kudashev, 2019-08-15 12:59:49

How to cancel the redrawing of functional components?

Hello, I have a global repository like Redux. With the help of the context, I distribute the state to the entire application:

<StoreProvider>
    <Router>
        <Fragment>
          <Header />
          <Main>
              <Literature />
          </Main>
        </Fragment>
    </Router>
</StoreProvider>

The Literature component has an input that changes this state. Because of this, the entire application starts to redraw. How do I cancel the redraw if the component is stateless. Tried to use React.memo , but it compares props. For example, the Header component does not accept props at all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Spirin, 2019-08-15
@archi_kud

export default React.memo(Header);

P
Philip Gaponenko, 2019-08-15
@filgaponenko

You can try using https://reactjs.org/docs/react-component.html#shou...
Return always false in this hook.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question