File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,18 @@ function getOrCreateStore(key: string): StoreCache {
3030 let store = stores . get ( key ) ;
3131 if ( ! store ) {
3232 const hostObject = getHostObject ( key ) ;
33+ if ( ! hostObject ) {
34+ throw new Error (
35+ `[Brownie] Store "${ key } " not found. ` +
36+ `Make sure to register it on the native side before accessing it from JS.\n\n` +
37+ `Swift example:\n` +
38+ ` ${ key } .register(${ key } (...))\n\n` +
39+ `This should be called before React Native starts.`
40+ ) ;
41+ }
3342 store = {
3443 hostObject,
35- snapshot : hostObject ? .unbox ?.( ) ?? { } ,
44+ snapshot : hostObject . unbox ?.( ) ?? { } ,
3645 listeners : new Set ( ) ,
3746 } ;
3847 stores . set ( key , store ) ;
@@ -85,7 +94,6 @@ export function setState<K extends keyof BrownieStores>(
8594 action : SetStateAction < BrownieStores [ K ] >
8695) : void {
8796 const store = getOrCreateStore ( key as string ) ;
88- if ( ! store . hostObject ) return ;
8997
9098 const partial =
9199 typeof action === 'function'
You can’t perform that action at this time.
0 commit comments