-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
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
Recoil selector와 selectorFamily의 Cache로 인한 문제점 #54
Labels
pending
Pending more information or user action
Comments
const userWithCheck = selectorFamily({
key: 'userWithCheck',
get: (token) => async () => {
const response = await check(token);
return response;
},
});
export const check = (token) => client.get(`${AUTH_PATH}/check`, {
headers: {
Authorization: token,
},
});
const fetchClient = () => {
const client = axios.create(setPath(process.env.NODE_ENV));
client.interceptors.request.use((config) => {
const token = getCookie('access_token');
// eslint-disable-next-line no-param-reassign
config.headers.Authorization = token || '';
return config;
});
return client;
}; |
저도 같은 문제로 고민중입니다 ㅎㅎ recoil의 캐싱기능으로 인해, data sync 가 안 맞는 경우에 대해서 마땅히 적정한 해결책을 떠오르지 못하겠네요. 저도 님처럼 임시방편적인 여러 방법으로 해결하고 있긴 하는데.. |
@saseungmin @stella6767 시간이 오래 지나 해결하셨겠지만,,, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
selectorFamily
를 사용할 때 파라미터를 사용하지 않는다. 다른 방법이 있을 듯 하다.📌 문제 원인
userWithCheck
를 실행하지 않고 기존의 값이 반환된다.selectorFamily
를 사용하여 해결하였는데selectorFamily
는 캐시 값을 확인할 때 파라미터와 key값과 get의존성을 확인하기 때문에 auth를 파라미터를 넘겨 cache가 안되게 해결해였다. 근데 더 좋은 방법이 있을 거 같다.The text was updated successfully, but these errors were encountered: