Recoil
Recoil copied to clipboard
[React Native] "Duplicate atom key"-warning in React Native/Expo
Hello. I have previously used Recoil in web applications without problems, and I love it's approach to globalized state. But I'm now implementing Recoil in a React Native/Expo app, and have encountered a warning that keeps following me. This is my code:
Where atom is created:
// globalState.js
const { atom } = require("recoil");
export const priceDataState = atom({
key: "priceDataState",
default: null
});
Where atom is used:
// Screen.js
import { useRecoilState } from 'recoil';
import { priceDataState } from "../globalState";
export default function HomeScreen({ navigation }) {
const [priceData, setPriceData] = useRecoilState(priceDataState);
return(
<Text>{priceData}</Text>
)
}
When I do this, I get the following warning in Expo GO:
Console warning: Duplicate atom key "priceDataState". This is a FATAL ERROR in production. But it is safe to ignore this warning if it occurred because of hot module replacement
An interesting and possibly important note is that the warning only seems to occur if I navigate to globalState.js
in VSCode and save the document, which results in a hot reload in Expo GO. The warning mentions something about "hot module replacement", which might be related to hot reload?
Thankful for any input on this. Is it a bug?
It seem like this would be addressed by now. Getting this in Stackblitz and other environments. Not using Next.js.

Me to have this problem and I don't find how I can go on next steps. Who and how maked it?
How can we use this in production with this bug?
There is a way to disable this error in 0.7.6. Please confirm it
https://github.com/facebookexperimental/Recoil/releases/tag/0.7.6