尝试使用useResetRecoilState
将反冲状态重置为其默认值,但不起作用这是我的代码
import {filter} from '..appl/recoil/atoms';
import { useResetRecoilState } from 'recoil';
let filterReset = () => { useResetRecoilState(filter); }
.
.
onSignOut = () => {
/*Code for signout and other stuff*/
filterReset();
}
反冲状态代码为:
import { atom, useRecoilState } from 'recoil';
export const filter = atom({
key: 'filter',
default: {
handlers: [],
product: '',
origin: '',
destination: ''
}
}
使用了该文档,但对没有帮助
useResetRecoilState返回一个重置反冲状态的函数。应该这样使用:
import {filter} from '..appl/recoil/atoms';
import { useResetRecoilState } from 'recoil';
onSignOut = () => {
const filterReset = useResetRecoilState(filter);
/*Code for signout and other stuff*/
filterReset();
}