papi-dts
    Preparing search index...

    Variable useWebViewState

    useWebViewState: UseWebViewStateHook

    A React hook for working with a state object tied to a webview. Returns a WebView state value and a function to set it. Use similarly to useState.

    Only used in WebView iframes.

    @param stateKey Key of the state value to use. The webview state holds a unique value per key.

    WARNING: MUST BE STABLE - const or wrapped in useState, useMemo, etc. The reference must not be updated every render

    @param defaultStateValue Value to use if the web view state didn't contain a value for the given 'stateKey'

    Note: this parameter is internally assigned to a ref, so changing it will not cause any hooks to re-run with its new value. Running resetWebViewState() will always update the state value returned to the latest defaultStateValue, and changing the stateKey will use the latest defaultStateValue. However, if defaultStateValue is changed while a state is defaultStateValue (meaning it is reset and has no value), the returned state value will not be updated to the new defaultStateValue. A state value showing defaultStateValue keeps that same object across updates to other keys of the web view state, but still pass a stable default (module-level or memoized) if the value is used in an effect's dependency list. Likewise, a saved value that is deeply equal to the current state value keeps the current object, so saving an equal new object does not give the state value a new identity.

    @returns [stateValue, setStateValue, resetWebViewState]

    • webViewStateValue: The current value for the web view state at the key specified or defaultStateValue if a state was not found
    • setWebViewState: Function to use to update the web view state value at the key specified
    • resetWebViewState: Function that removes the web view state and resets the value to defaultStateValue

    @example

    const [lastPersonSeen, setLastPersonSeen] = useWebViewState('lastSeen', 'No one');