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.
@paramstateKey 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
@paramdefaultStateValue 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 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. RunningresetWebViewState()
will always update the state value returned to the latestdefaultStateValue
, and changing thestateKey
will use the latestdefaultStateValue
. However, ifdefaultStateValue
is changed while a state isdefaultStateValue
(meaning it is reset and has no value), the returned state value will not be updated to the newdefaultStateValue
.@returns
[stateValue, setStateValue, resetWebViewState]
webViewStateValue
: The current value for the web view state at the key specified ordefaultStateValue
if a state was not foundsetWebViewState
: Function to use to update the web view state value at the key specifiedresetWebViewState
: Function that removes the web view state and resets the value todefaultStateValue
@example