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

Error: 🟥 @prisma/react-native failed to initialize #39

Open
xavier-brandares opened this issue Sep 28, 2024 · 1 comment
Open

Error: 🟥 @prisma/react-native failed to initialize #39

xavier-brandares opened this issue Sep 28, 2024 · 1 comment

Comments

@xavier-brandares
Copy link

I'm on the latest build as of September 28, 2024

I'm getting the Error:

Error: 🟥 @prisma/react-native failed to initialize

Here are the steps I've taken and how I built the project:

Firstly, I've made the expo project:

npx create-expo-app@latest

Then I cd into the project and install the dependencies:

npm install

Then I connected the expo app to the expo go dashboard:

eas init --id <id_string>

Then I run the app on the ios simulator:

npx expo start --ios

Everything is good and works, so I go ahead and install prisma:

npm i --save --save-exact @prisma/client@latest @prisma/react-native@latest react-native-quick-base64

then I modify the app.json plugin section as follow:

{
  "expo": {
    // ... The rest of your expo config
    "plugins": ["@prisma/react-native"]
  }
}

Then I run the following:

npx expo prebuild --clean

Then I initialize prisma

npx prisma init

Then I edit the schema with the following models:

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["reactNative"]
}

datasource db {
  provider = "sqlite"
  url      = "file:./app.db"
}

// Your data model

model User {
  id           Int     @id @default(autoincrement())
  name         String
}

Then I run a migration:

npx prisma@latest migrate dev

Then I generate prisma:

npx prisma@latest generate

Then I make a db.ts file to use reactive queries:

import { PrismaClient } from '@prisma/client/react-native';
import { reactiveHooksExtension } from '@prisma/react-native';

const baseClient = new PrismaClient();

export const extendedClient = baseClient.$extends(reactiveHooksExtension());

Then I modify my component to use prisma:

import { Text } from 'react-native';
import { extendedClient } from './myDbModule';

export default function App {

  // Will automatically re-render the component with new data
  const users = extendedClient.user.useFindMany();

  return (
    <Text>{ users }</Text>
  )
}

Then I restart the app:

npx expo start --ios

Then I get this error:

Simulator Screenshot - iPhone 16 Plus - 2024-09-28 at 09 27 28

@xavier-brandares
Copy link
Author

xavier-brandares commented Sep 28, 2024

Related issue 23 is still open and has not been resolved.

I use prisma for NextJS and it works flawlessly, sucks that this issue completely hard locks the package.

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

1 participant