main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
507 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import { useMemo, useRef } from 'react';
|
---|
| 2 | import useUpdate from './useUpdate';
|
---|
| 3 | import { resolveHookState } from './misc/hookState';
|
---|
| 4 | export default function useGetSet(initialState) {
|
---|
| 5 | var state = useRef(resolveHookState(initialState));
|
---|
| 6 | var update = useUpdate();
|
---|
| 7 | return useMemo(function () { return [
|
---|
| 8 | function () { return state.current; },
|
---|
| 9 | function (newState) {
|
---|
| 10 | state.current = resolveHookState(newState, state.current);
|
---|
| 11 | update();
|
---|
| 12 | },
|
---|
| 13 | ]; }, []);
|
---|
| 14 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.