fix: storage not selecting first entry in pallet

This commit is contained in:
Victor Oliva
2025-03-11 14:45:19 +01:00
parent 29c1665e8a
commit 37004cb297

View File

@@ -31,13 +31,14 @@ const createExternalStateHook = (externalState: ExternalState) => {
parse: (value) => value as T,
},
) {
const state = externalState.hasValue(key)
? parser.parse(externalState.getValue(key))
: defaultValue
const [_state, _setState] = useState(state)
const [_state, _setState] = useState(() =>
externalState.hasValue(key)
? parser.parse(externalState.getValue(key))
: defaultValue,
)
return [
state,
_state,
(newValue: ValueOrReducer<T>) => {
_setState((prev) => {
const value: T =