do not try to update state if it is not yet set

This happens when the backend pushes updates before the frontend has received and set the state when loading the page, first.
This commit is contained in:
Mose Müller 2024-03-05 13:19:02 +01:00
parent 8b1f1ef1b1
commit dba036c6b3

View File

@ -32,6 +32,9 @@ const reducer = (state: State, action: Action): State => {
case 'SET_DATA':
return action.data;
case 'UPDATE_ATTRIBUTE': {
if (state === null) {
return null;
}
return {
...state,
value: setNestedValueByPath(state.value, action.fullAccessPath, action.newValue)