Просмотр исходного кода

Use scopeStore in useScopeValueSetterOnly (#16341)

GitOrigin-RevId: ed3c5937bafc984440ee262c8cb0c1ba63f0be7d
Alf Eaton 2 лет назад
Родитель
Сommit
12646d0541

+ 3 - 3
services/web/frontend/js/shared/hooks/use-scope-value-setter-only.ts

@@ -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]