title: React Context API with Typescript Generic
body: <pre><code>type ContextProps&lt;T = object&gt; = {
    store: T,
    updateStore: React.Dispatch&lt;T&gt;
  };
  
  export default React.createContext&lt;Partial&lt;ContextProps&gt;&gt;({}); // is there any way to pass the generic? so store can correct type
  
  export function Provider&lt;T, K&gt;(props: T &amp; { store: K }) {
    const [globalState, updateStore] = React.useState(props.store);
    const value = React.useMemo(
      () =&gt; ({
        store: globalState,
        updateStore,
      }),
      [globalState],
    );
  
    return &lt;StateMachineContext.Provider value={value} {...props} /&gt;;
  }
  </code></pre>
  <p>Is there any way to pass generic into Context, so <code>value</code> can have the correct type?</p>