Skip to content

useSWRMutation is not working with React Native New Architecture. #2986

@ShineKidd

Description

@ShineKidd

Bug report

Repro Steps / Code Example

  1. npx create-expo-app@latest

configure app.json

 "plugins": [
      "expo-router",
      [
        "expo-build-properties",
        {
          "ios": {
            "newArchEnabled": true
          },
          "android": {
            "newArchEnabled": true
          }
        }
      ]
    ],
  1. home.tsx code example
import useSWRMutation from 'swr/mutation'

function Home () {
  const {trigger, data, error} = useSWRMutation('https://github.com', (key) => fetch(key).then(res => res.text()))

  console.log({data, error}) // always print {"data": undefined, "error": undefined}

  function submit () {
    // print error: "(NOBRIDGE) ERROR  [TypeError: Cannot read property 'add' of undefined]"
    trigger().then(console.log).catch(console.error)
  }

  return  (
     <View>
       <Button title='mutation' onPress={submit}></Button>
     </View>
     )
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions