React Native Expo template: problems and solutions

I just thought I would share a couple pieces of information about the Expo template, since I know myself and others have encountered some difficulties with it.

There was a problem where the template was installing some incompatible Realm/Expo versions. Since Expo 48 was officially released, I decided to try the template again and bump everything (realm, expo and friends, @realm/react) to latest, and it worked. Previously this had failed for me (using Expo 48 beta). I don’t know if the template was updated and that played a role, but either way good news!

When I started the template app, everything looks like it should, but once you enter a todo, the IntroText disappears but no to-dos show up. I seem to recall this happening in previous attempts to use the template but can’t say for sure. I dug around a bit and the problem is in the TaskList component, it renders a FlatList as such:

  keyExtractor={task => task._id.toString()}
  renderItem={({ item }) => (
      onToggleStatus={() => onToggleTaskStatus(item)}
      onDelete={() => onDeleteTask(item)}
      // Don't spread the Realm item as such: {...item}

But the FlatList isn’t even receiving elements to render. If you run Array.isArray(tasks) it’s false, I’m not sure what tasks is, but it’s not an array. I just spread it into an array, eg


and that fixed it. If you call tasks.toString() it returns [Function bound value], not sure what that indicates.

Thought I would share in case it helps the maintainers and other people trying to figure out how to use Realm.


Note: the rendering problem I describe is with the nonsync version, although I’m not sure if that effects it.

Update: The same problem with FlatList rendering happens in a sync version as well, so that wasn’t the problem. The useQuery documentation says that the value returned from useQuery can be passed directly to a FlatList’s data prop but this seems to be broken. Easy to fix by spreading it into an array, just trying to point out some sticking points.

@Brian_Luther , are you able to run the project with Expo Go? Could you possibly share a repo or a package.json?

PS: Thank you for going out of your way to inform us of your success with this big problem.

@Brian_Luther There was a restriction on FlatList introduced in React Native 0.71.0. We have brought this to the attention of Meta and they have made FlatList Realm compatible in 0.71.4. You should be able to upgrade the RN dependency to 0.71.4 in your package.json, as the upgrade path from 0.71.3 to 0.71.4 does not require any changes to native code.

@Damian_Danev Realm is not compatible with Expo Go, as it is not included in the base SDK of Expo. One has to compile their own dev-client (similar to a custom Expo Go) either locally or through EAS.

@Andrew_Meyer , do you think there is a chance the Expo team will include Realm in the base SDK of Expo any time soon or at all?

@Damian_Danev They will not. They have even removed react-native-reanimated from the base SDK. My understanding is that they are pushing towards the dev-client if you need any third party library. They are also giving library authors, like us, the ability to provide configurations that can patch native parts, so that expo users can still have a much easier experience using React Native.
It makes sense, as each app has their own set of needs when it comes to what libraries they use. Any library that is adding native code to the app will increase the amount of disc space, so you would want to keep this light anyway.

I haven’t used Expo Go yet, it should be possible to do so using a development build (see Create development builds - Expo Documentation under “On a device”) but I haven’t tried yet, I’ve been using the iOS simulator. Here’s a copy of my package.json:

  "name": "gv2-r",
  "main": "index.js",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios"
  "dependencies": {
    "@expo/vector-icons": "^13.0.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@realm/react": "^0.4.3",
    "expo": "~48.0.6",
    "expo-constants": "~14.2.1",
    "expo-dev-client": "~2.1.5",
    "expo-linking": "~4.0.1",
    "expo-router": "^1.2.2",
    "expo-splash-screen": "~0.18.1",
    "expo-status-bar": "~1.4.4",
    "luxon": "^3.3.0",
    "react": "18.2.0",
    "react-native": "0.71.3",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-get-random-values": "~1.8.0",
    "react-native-reanimated": "~2.14.4",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "realm": "^11.5.2"
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/plugin-proposal-decorators": "^7.19.0",
    "@realm/babel-plugin": "^0.1.1",
    "@types/react": "~18.0.14",
    "@types/react-native": "~0.70.6",
    "typescript": "^4.9.4"
  "private": true

That explains it, thanks. I was able to upgrade to react-native to 0.71.4 without issue so far. Running npx expo install --fix will downgrade back to 0.71.3 but I’m assuming that’s because something doesn’t official support 0.71.4?

I’m assuming that’s because something doesn’t official support 0.71.4 ?

@Brian_Luther Expo usually releases at the most current React Native at the time of the release. It’s possible that they haven’t seen it as a priority to update this internally, but there isn’t anything in this update that would be incompatible with Expo. I’ll ping the Expo team to make an update to the Expo SDK to support this patch release.

Expo says they will soon do a release and have a PR for this to be officially updated.

Nice, that was fast, thanks Andrew

1 Like