title: could not find react-redux context value error triggering randomly
body: <p>Here is my code for displaying the contents of my Redux store state in JSON:</p>
  <pre><code>   function ShowCartContents() {
        // Convert object to JSON before rendering
        const cartContentsJSON = JSON.stringify(useStore().getState())
      
        return (
          &lt;div&gt;
              &lt;h2&gt;Cart contents: {cartContentsJSON}&lt;/h2&gt;
            &lt;/div&gt;
        );
      }
  // Works fine
  </code></pre>
  <p>Everything is working just fine but when I try to add button with onClick attribute to call another function I'm getting error:</p>
  <pre><code>Error: could not find react-redux context value; please ensure the component is wrapped in a &lt;Provider&gt;
  </code></pre>
  <p>The weird thing here is that I do have <code>&lt;App&gt;</code> wrapped in <code>&lt;Provider&gt;</code> but this error occurs and I can't find any logic why this happens. Here is the beginning of my <code>App.js</code>:</p>
  <pre><code>    import './App.css';
      import MenuItems from './components/Navbar/MenuItems';
      import ReactDOM from 'react-dom';
      import React, { useState } from 'react';
      import { createStore } from 'redux';
      import {AddItemToCart, DeleteItemFromCart, Counter} from './cart.js';
      import Header from './header';
      import Footer from './footer.js';
      import { render } from &quot;react-dom&quot;;
      import { Provider } from &quot;react-redux&quot;;
      import { useSelector, useStore } from 'react-redux';
      
      let store = createStore(Counter);
      const rootElement = document.getElementById(&quot;root&quot;);
      render(
        &lt;Provider store={store}&gt;
          &lt;App /&gt;
        &lt;/Provider&gt;,
        rootElement
      );
  const [customerInfo, setCustomerInfo] = useState([])
  </code></pre>
  <p>Here is how I tried to add my button with OnClick for function call:</p>
  <pre><code>    function ShowCartContents() {
        const cartContentsJSON = JSON.stringify(useStore().getState())
      
        return (
          &lt;div&gt;
              &lt;h2&gt;Cart contents: {cartContentsJSON}&lt;/h2&gt;
              &lt;button onClick={(e)=&gt; {ShowCustomerInfo(e)}}&gt;Proceed&lt;/button&gt;
  // Also tried: &lt;button onClick={&lt;ShowCustomerInfo/&gt;}&gt;Proceed&lt;/button&gt;
            &lt;/div&gt;
        );
      }
  </code></pre>
  <p>This triggers the error above. Here is my <code>ShowCustomerInfo</code> function:</p>
  <pre><code>function ShowCustomerInfo(){
    fetch(`http://127.0.0.1:5000/getCustomerInfo`)
        .then(response =&gt; response.json())
        .then(response =&gt; {
            setCustomerInfo(response.result);
            console.log(response.result);
        });
        return (
          &lt;div&gt;
            &lt;h2&gt;
              {customerInfo}
            &lt;/h2&gt;
          &lt;/div&gt;
        );
  }
  </code></pre>
  <p>What is causing the exception? Any advise would be highly appreciated.</p>