mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 02:00:10 +02:00
Use scopeStore in useScopeValueSetterOnly (#16341)
GitOrigin-RevId: ed3c5937bafc984440ee262c8cb0c1ba63f0be7d
This commit is contained in:
@@ -19,7 +19,7 @@ export default function useScopeValueSetterOnly<T = any>(
|
||||
path: string, // dot '.' path of a property in the Angular scope.
|
||||
defaultValue?: T
|
||||
): [T | undefined, Dispatch<SetStateAction<T | undefined>>] {
|
||||
const { $scope } = useIdeContext()
|
||||
const { scopeStore } = useIdeContext()
|
||||
|
||||
const [value, setValue] = useState<T | undefined>(defaultValue)
|
||||
|
||||
@@ -27,11 +27,11 @@ export default function useScopeValueSetterOnly<T = any>(
|
||||
(newValue: SetStateAction<T | undefined>) => {
|
||||
setValue(val => {
|
||||
const actualNewValue = _.isFunction(newValue) ? newValue(val) : newValue
|
||||
$scope.$applyAsync(() => _.set($scope, path, actualNewValue))
|
||||
scopeStore.set(path, actualNewValue)
|
||||
return actualNewValue
|
||||
})
|
||||
},
|
||||
[path, $scope]
|
||||
[path, scopeStore]
|
||||
)
|
||||
|
||||
return [value, scopeSetter]
|
||||
|
||||
Reference in New Issue
Block a user