title: How to pass a web worker instance to another component in react js?
body: <p>Is it possible to pass a web worker instance to another component in react js?</p>
  
  <p>If I start a web worker in one component and then I navigate to another component, should I terminate the previous worker and start a new worker? What are the best practices?</p>
  
  <p>How do I listen to post message event of a web worker in two different react components?</p>
  
  <p>Scenario:
  There is a search input and a search button. As soon as user starts typing in the input, after 2 sec delay, I start a web worker in the background to get data from a remote server. When results are back, it is shown in the suggestions below the input. But if the user clicks the search button, before the worker has finished, it navigates to second component, then how do I access the worker instance in the second component?</p>