diff --git a/striker-ui/lib/buildObjectStateSetterCallback.ts b/striker-ui/lib/buildObjectStateSetterCallback.ts index 15170e85..98cecfcf 100644 --- a/striker-ui/lib/buildObjectStateSetterCallback.ts +++ b/striker-ui/lib/buildObjectStateSetterCallback.ts @@ -1,9 +1,13 @@ const buildObjectStateSetterCallback = - >(key: keyof S, value: S[keyof S]) => - ({ [key]: toReplace, ...restPrevious }: S): S => - ({ - ...restPrevious, - [key]: value, - } as S); + >(key: keyof S, value?: S[keyof S]) => + ({ [key]: toReplace, ...restPrevious }: S): S => { + const result = { ...restPrevious } as S; + + if (value !== undefined) { + result[key] = value; + } + + return result; + }; export default buildObjectStateSetterCallback;