realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Warning: TypeError: Cannot read property 'RealmProvider' of undefined

Open zainlinux1989 opened this issue 1 year ago • 1 comments

How frequently does the bug occur?

Always

Description

I am using realm 11.10.2 and @realm/react 0.5.2 version but my app always crashes in debug mode. i am using following code

import {createRealmContext, RealmProvider} from '@realm/react'

export class FoodSchema extends Realm.Object<FoodSchema> {
  id: string = ''
  name: string = ''
  foodGroup: string = ''
  calories: number = 0
  fat: number = 0
  count: number = 0
  timestamp: string = ''

  static schema = {
    name: SchemaName.Food,
    primaryKey: 'id',
    properties: {
      id: 'string',
      name: 'string',
      foodGroup: 'string',
      calories: 'double',
      fat: 'double',
      count: 'int',
      timestamp: 'string',
    },
  }
}
 return (
    <RealmProvider schema={[FoodSchema]}>
      <View style={{flex: 1, backgroundColor: 'green'}} />
    </RealmProvider>
  )

Stacktrace & log output

Warning: SyntaxError: JSON Parse error: Unexpected character: p, js engine: hermes  
ERROR  Warning: TypeError: Cannot read property 'RealmProvider' of undefined

This error is located at:
    in AppAndroid (created by RNRedux)
    in PersistGate (created by RNRedux)
    in Provider (created by RNRedux)
    in ThemeProvider (created by RNRedux)
    in $97d95f6660b1bb14$export$9f8ac96af4b1b2ae (created by NativeBaseProvider)
    in ToastProvider (created by NativeBaseProvider)
    in PortalProvider (created by NativeBaseProvider)
    in HybridProvider (created by NativeBaseProvider)
    in ResponsiveQueryProvider (created by NativeBaseProvider)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by NativeBaseProvider)
    in NativeBaseConfigProviderProvider (created by NativeBaseProvider)
    in NativeBaseProvider (created by RNRedux)
    in RNGestureHandlerRootView (created by GestureHandlerRootView)
    in GestureHandlerRootView (created by RNRedux)
    in RNRedux
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in MeFit(RootComponent), js engine: hermes

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

11.10.2

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Android 14

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

zainlinux1989 avatar Aug 31 '24 20:08 zainlinux1989

Thanks for your contribution, we're working on reviewing it!

olonho avatar Feb 01 '22 06:02 olonho

@olonho I've done the necessary changes. Please have a look

thelumiereguy avatar Feb 04 '22 17:02 thelumiereguy

@AlexeyTsvetkov I've made the necessary changes and answered some of your questions above. Please have a look at them when you have time. Thank you!

thelumiereguy avatar Feb 26 '22 16:02 thelumiereguy