Skip to content
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

onSuccess not called after upgrading from Expo 51 to 52 #3040

Open
ningacoding opened this issue Nov 13, 2024 · 1 comment
Open

onSuccess not called after upgrading from Expo 51 to 52 #3040

ningacoding opened this issue Nov 13, 2024 · 1 comment

Comments

@ningacoding
Copy link

ningacoding commented Nov 13, 2024

Bug report

Description / Observed Behavior

onSuccess option is not called after upgrading from Expo 51 to 52

react: 18.3.1
expo: 52.0.4

Expected Behavior

onSuccess to be called after fetcher promise is resolved (WORKS on Web, the bug occurs on Android)

Repro Steps / Code Example

  import useSWRMutation from 'swr/mutation';
  
  const {
    data: pokemons,
    trigger: getPokemons,
    isMutating: isLoading
  } = useSWRMutation(url, {
    onSuccess: (result) => console.log(result), // not called // before upgrading this worked
  });

  useEffect(() => {
    getPokemons(); 
  }, []);

Additional Context

swr: 2.2.5

There is a chance this error is related to the new React Architecture since hooks also stop to propagate fetcher results.

in order to use the new React Architecture with Expo, create an Expo 52 project and add/update this line in app.json:

"newArchEnabled": true,

Under { "expo": { here } }

Re-launch app after clearing cache.

@MasterSigmar
Copy link

MasterSigmar commented Nov 13, 2024

Getting something very similar here on our android dev build with new arch disabled :

"axios": "^1.7.7", <--- axios instance as fetcher
"expo": "^51.0.38",
"react": "18.2.0",
"react-native": "0.74.5",
"swr": "^2.2.5",
"typescript": "~5.3.3"

I even added resolutions to make sure peer deps use the same versions we have installed :

"resolutions": {
  "react": "18.2.0",
  "react-native": "0.74.5",
  "@types/react": "~18.2.45"
},
"packageManager": "[email protected]"

Adding a .then() to the fetcher seems like axios is correctly making the call and correctly returning the response to swr.
Happens very intermittently, some calls work just fine and some don't. Seems pretty random, doesn't seem related to a certain endpoint. When that happens, onSuccess is indeed not called and the data returned by the swr hook is always undefined.

EDIT: lookin at the changelogs it seems that the last release for swr was in February and this issue has been a fairly recent(last couple of weeks) thing for us. Which makes me wonder if perhaps a peer deps or something that swr depends on might have introduced some kind of bug that makes this happen. 🤔

EDIT2: Could it be related to the latest android versions I wonder 🤔. Happens also on a tablet emulator on android 11.0 ("R") | x86 API 30
Phone/tablet, physical device/emulator doesn't seem to make a difference either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants