0

The following code, where each component includes <Subscribe to={[ZebraContainer]}> causes ZebraContainer to be constructed three times. Is there an accepted pattern to maintain ZebraContainer as a global singleton and only construct once?

  <Provider>
    <BrowserRouter>
      <div className="App">

        ...

        <Route path="/foo" component={Foo} />
        <Route path="/bar" component={Bar} />
        <Route path="/baz" component={Baz} />

      </div>
    </BrowserRouter>
  </Provider>

1 Answer 1

1

In unstated containers ARE singletons. They aren't reconstructed when the components rerender.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.