title: How to share a specific variable between different react components
body: <p>I have 2 sibling components <strong>home</strong> and <strong>history</strong> where home has the following function</p>
  <pre><code>//home
  function handledata() {
      const key = uuidv4();
      localStorage.setItem(key, JSON.stringify(formdata));
    }
  </code></pre>
  <p>I need to access local storage in the sibling <strong>history</strong> component so how do i access this key variable there</p>
  <pre><code>//history
  const [items, setItems] = React.useState([]);
    const handledata = () =&gt; {
      localStorage.getItem(key);
    };
  </code></pre>
  <p>Complete code of both files <a href="https://github.com/Megahedron69/testrep" rel="nofollow noreferrer">https://github.com/Megahedron69/testrep</a></p>