Derived atoms fail to update simultaneously with their base atom in React Native #2635
Unanswered
nelyousfi
asked this question in
Bug report
Replies: 2 comments 2 replies
-
If that's the case, it's expected and |
Beta Was this translation helpful? Give feedback.
0 replies
-
@dai-shi thanks for getting back. What about tests? Something like the test below fails even after enabling the react native new architecture. import React from 'react';
import {fireEvent, render, waitFor} from '@testing-library/react-native';
import App from './App';
describe('App', () => {
it('login and logout', async () => {
const screen = render(<App />);
const LoginButton = screen.getByText('Login');
fireEvent.press(LoginButton);
await waitFor(() => {
expect(screen.getByText('Welcome Home John Doe')).toBeOnTheScreen();
});
const LogoutButton = screen.getByText('Logout');
fireEvent.press(LogoutButton);
await waitFor(() => {
expect(screen.getByText('Welcome To Login')).toBeOnTheScreen();
});
});
}); The same issue, |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Description
What is the issue?
Hello folks,
Thank you for the amazing job you're doing with Jotai!
I encountered an issue while using Jotai with React Native. It appears that derived atoms are not updating simultaneously with their base atom.
How can it be reproduced?
When pressing the logout button, the code above is throwing the
User is null
error.I've tested similar code on React JS and with the new React Native architecture enabled, and it works fine. Therefore, I suspect the issue lies with the old React Native architecture renderer.
Also, wrapping the
setUser
function withunstable_batchedUpdates
seems to fix the issue.Environment:
Jotai: 2.8.3
react-native: 0.73.2
RN new architecture: disabled
Reproduction Link
https://github.com/nelyousfi/RNLab73Jotai
Beta Was this translation helpful? Give feedback.
All reactions