Methods
defaultGetUpdate()
- Source:
A hook that handles the mutate operations on a state's member.
Example
const [title, setTitle, error, setError] = useMember({
fieldKey: 'title'
});
setTitle('hello'); // state.title === 'hello'
setError('myError'); // state.errors.title === 'myError'
makeWithUniq()
- Source:
A hook that handles the CRUD operations on a state's collection.
Example
const {collection, add, push, edit, remove, error, setError} = useCollection({
fieldKey: 'skills'
});
push('my'); // collection [my]
add(0, 'hello'); // collection[hello, my]
add(1, 'world'); // collection[hello, world, my]
edit(2, 'sorry'); // collection[hello, world, sorry]
remove(2); // collection[hello, world]
usePrevious()
- Source:
A hook for keeping the previous state of a value
Example
const Foo = ({bar}) => {
const previousBarRef = usePrevious(bar);
return (
<Fragment>
it was {previousBarRef.current} and became {bar}
<button onClick={changeBar}>Change bar</button>
</Fragment>
);
}