我可以将 Recoil 原子的默认值设置为对象吗?
例如:
export const currentUserState = atom({
key: 'currentUserState',
default: { name: '', email: '', userId: null },
});
然后将其设置为:
import { currentUserState } from '../atoms/atoms';
const setUserState = useSetRecoilState(currentUserState);
setUserState(name: 'John', email: 'foo@bar.com', userId: getRand());