Reputation: 51
tried to reset recoil state to its default value using useResetRecoilState
but not working
This is my code
import {filter} from '..appl/recoil/atoms';
import { useResetRecoilState } from 'recoil';
let filterReset = () => { useResetRecoilState(filter); }
.
.
onSignOut = () => {
/*Code for signout and other stuff*/
filterReset();
}
recoil state code is :
import { atom, useRecoilState } from 'recoil';
export const filter = atom({
key: 'filter',
default: {
handlers: [],
product: '',
origin: '',
destination: ''
}
}
used this documentation but didn't help
Upvotes: 0
Views: 3952
Reputation: 555
useResetRecoilState returns a function that resets the recoil state. It should be used like this:
import {filter} from '..appl/recoil/atoms';
import { useResetRecoilState } from 'recoil';
onSignOut = () => {
const filterReset = useResetRecoilState(filter);
/*Code for signout and other stuff*/
filterReset();
}
Upvotes: 2