Skip to content

Commit

Permalink
fix: ensure that useStructureToolSetting updates only when necessary (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cngonzalez committed Mar 15, 2024
1 parent 1041460 commit a4d8d2d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/sanity/src/structure/useStructureToolSetting.ts
Expand Up @@ -38,10 +38,12 @@ export function useStructureToolSetting<ValueType>(

const set = useCallback(
(newValue: ValueType) => {
setValue(newValue)
keyValueStore.setKey(keyValueStoreKey, newValue as string)
if (newValue !== value) {
setValue(newValue)
keyValueStore.setKey(keyValueStoreKey, newValue as string)
}
},
[keyValueStore, keyValueStoreKey],
[keyValueStore, keyValueStoreKey, value],
)

return useMemo(() => [value, set], [set, value])
Expand Down

0 comments on commit a4d8d2d

Please sign in to comment.