We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我现在是借助了 jotai 来进行状态同步,这个默认行为可能需要在文档提示一下?
const uiContainerAtom = atom('narrow'); export function useUiContainer() { const [cookieValue, updateCookie, refreshCookie] = useCookie('ui.is-container', {}, 'narrow'); const [uiContainer, setUiContainer] = useAtom(uiContainerAtom); const onToggle = () => { updateCookie(cookieValue === 'full' ? 'narrow' : 'full'); setUiContainer((prev) => (prev === 'full' ? 'narrow' : 'full')); refreshCookie(); }; useEffect(() => { setUiContainer(cookieValue || 'narrow'); }, [cookieValue, setUiContainer]); const isFull = useMemo(() => uiContainer === 'full', [uiContainer]); return { isFull, onToggle, }; }
The text was updated successfully, but these errors were encountered:
很抱歉这么晚才回复,我一直在思考这个问题,预计后面会使用 useSyncExternalStore 来重构这个 hook, 看能否达到广播的效果。
useSyncExternalStore
Sorry, something went wrong.
useCookie应该不会添加广播功能,因为这样相当于在内部维护了一个状态管理库,我觉得使用外部的状态管理库来同步是更好的选择,文档已经加了提示。#92
No branches or pull requests
我现在是借助了 jotai 来进行状态同步,这个默认行为可能需要在文档提示一下?
The text was updated successfully, but these errors were encountered: