Source:  Twitter logo

I'm trying the new state management library from facebook recoil, I tried the Getting started example on a reactjs project and it worked perfectly. After that I tried recoil on a react-native project but I got an error:

Here's the code I've tried:


import React from 'react';
import {RecoilRoot} from 'recoil';
import RecoilTest from './RecoilTest';

const App = () => {
  return (
      <RecoilTest />

export default App;


import React from 'react';
import {useRecoilState} from 'recoil';
import {View, Text} from 'react-native';
import {textState} from './Atoms';

const RecoilTest = () => {
  const [text, setText] = useRecoilState(textState);
  return (

export default RecoilTest;


import {atom} from 'recoil';

export const textState = atom({
  key: 'textState',
  default: 'initial value',

Recoil don't has a fully support to react native yet

3 users liked answer #0dislike answer #03
hackemate profile pic

Towards release

See here

Hi everyone! FYI we've published a "nightly build" branch for testing purposes. If you want to try out recoil with react native before we release next version, try install the nightly branch with the "install git branch" feature of npm/yarn:

npm install

Or yarn add

2 users liked answer #1dislike answer #12
Yoel profile pic

It is supported in nightly build. If you want to try before it is released with next version, you can install it doing:

yarn add

The update can be followed in this PR

2 users liked answer #2dislike answer #22
Black profile pic

Update: RN support is now there in Recoil.js as Experimental.

2 users liked answer #3dislike answer #32
Yogesh Agrawal profile pic
Yogesh Agrawal

Try using 'useRecoilValue' instead in your RecoilTest.js file

const [text, setText] = useRecoilValue(textState);
-2 users liked answer #4dislike answer #4-2
divsoup profile pic

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).