React has a virtual DOM which will maintain the states and the re-renders on state changes. Using this approach it can have track of the components connected to the provider. It is a kind of subscriber pattern. If the child component is out of the provider then it is not subscribed. In case it falls inside, then it is subscribed.