title: pass existing context to my setContext react hook (JS question)
body: <p>My current context with a method to set the updated context looks like this:</p>
  <pre><code>export const AppContextProvider = ({ children }) =&gt; {
    const [currentAppContext, setCurrentAppContext] = useState(initApp)
  
    const setAppContext = values =&gt; {
      setCurrentAppContext(values)
    }
  
    return &lt;AppContext.Provider value={{ appContext: currentAppContext, setAppContext }}&gt;{children}&lt;/AppContext.Provider&gt;
  }
  </code></pre>
  <p>and I set the new context in a component like so:</p>
  <pre><code>export default function Settings() {
    const { appContext, setAppContext } = useContext(AppContext)
  
    const func = ({ accountId }) =&gt; {
        setAppContext({
          ...appContext,
          accountId: accountId,
        })
      },
    })
    return &lt;&gt;&lt;/&gt;
  }
  </code></pre>
  <p><strong>But I would prefer to do just</strong> <code>setAppContext((currentContext) =&gt; ({...currentContext, accountId: accountId}))</code> like we do in the <code>useReducer</code> hook <code>useReducer(state =&gt; state.item)</code> kind of thing. Is this possible, if so, how would I write it?</p>