All relatively basic Hook methods.
Show/hide switch Hook
import {useShow} from '@acrook/react-hooks';
import {useEffect} from "react";
const Example = () => {
const { isShow, show, hide, toggle} = useShow();
return <>
<p>isShow: {String(isShow)}</p>
<button onClick={show}>Show</button>
<button onClick={hide}>Hide</button>
<button onClick={toggle}>toggle</button>
</>;
}
Only executed when componentDidUpdate
import {useUpdateEffect} from '@acrook/react-hooks';
import {useEffect} from "react";
const Example = () => {
useUpdateEffect(() => {
console.log('update!');
}, []);
}