Skip to content

Commit

Permalink
usereactives
Browse files Browse the repository at this point in the history
  • Loading branch information
YousefED committed May 2, 2021
1 parent 0fda5c2 commit b814fd6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/reactive-react/src/useReactive.ts
Expand Up @@ -14,3 +14,18 @@ export function useReactive<T>(stateObject: T): T {

return ret;
}

export function useReactives<T extends any[]>(...stateObjects: T): T {
const [, forceUpdate] = useReducer((c) => c + 1, 0);
const trigger = {
trigger: () => {
forceUpdate();
},
};

return useMemo(() => {
return stateObjects.map((stateObject) => {
return reactive(stateObject, trigger);
});
}, []) as T;
}

0 comments on commit b814fd6

Please sign in to comment.