我使用RecoilJS在下一个页面之间传递全局状态。这很好,直到我在接收变量的页面中使用next-i18next。如果我注释掉接收页面的getServerSideProps中的下一个-i18Next代码,反冲原子将被正确地传递。
export const getServerSideProps = withAuthUserSSR({ whenUnauthed:
AuthAction.REDIRECT_TO_LOGIN,})(async ({ AuthUser, req, locale }) => {
return {
props: {
// ...(await serverSideTranslations(locale,
// [
// 'sidebar',
// 'search',
// ...
// ]
// )),
},
};
})但是,如果我取消注释这段代码,我的一个变量就会被阻塞。我确实需要使用next-i18next。有人能解释一下为什么它会被封锁吗?
我有三个后坐力原子,并且正在使用后坐力持久化在页面之间持久化数据,正如我所理解的,后坐力通常不会这样做:
import { recoilPersist } from 'recoil-persist'
import { atom } from "recoil";
const { persistAtom } = recoilPersist({ key: 'RSKatom' })
export const newUser = atom({
key: "newUser",
default: false,
effects_UNSTABLE: [persistAtom],
})
export const newUserAvatar = atom({
key: "newUserAvatar",
default: null,
effects_UNSTABLE: [persistAtom],
})
export const newName = atom({
key: "newName",
default: "",
effects_UNSTABLE: [persistAtom],
})不寻常的是,“newUser”和“newName”都通过了,但是“newUserAvatar”没有。这用于存储文件输入字段的值,当下一个-i18Next代码被取消注释时,'newUserAvatar‘总是成为一个空对象,并且控制台记录为’反冲阿凡达:{}‘。
对于上面注释掉的代码,它可以工作,这是console.log:
RECOIL AVATAR: File {name: 'sample-avatar.jpeg', lastModified: 1639308280770, lastModifiedDate: Sun Dec 12 2021 19:24:40 GMT+0800 (Central Indonesia Time), webkitRelativePath: '', size: 14744, …}有人能帮忙吗?
编辑:我不认为这是特定的后坐力。我也尝试了,结果也是一样的。
https://stackoverflow.com/questions/70332073
复制相似问题