C
C
Ceretean2019-02-27 16:02:39
React
Ceretean, 2019-02-27 16:02:39

How to make a component in react that will be available on all pages?

There was a need to open a modal window for a user who has not changed his data in the personal account for a long time. It is necessary that it opens independently several times a day and regardless of which page the user is on, and there are many pages.
Is it possible to somehow implement a component that will be available from everywhere, without having to import it on every page? Tell me which way to dig? Maybe portals, maybe somehow you can run from redax, but the main thing is that the modal is initialized once.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Okhotnikov, 2019-02-27
@Ceretean

Connect it in the main component or in the component with the router

<Fragment>
  <Modal />
  <Router />
</Fragment>

So it will load once for you - and then, depending on the router, the content of the pages will change

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question