I find a weird behaviour when writing my vite program,
import { Store } from '@decky.fx/react-native-essentials/lib/index';
the code above is working fine, but if i change it into
import { Store } from '@decky.fx/react-native-essentials';
Store will yield undefined
I have to load all modules like this
import All from '@decky.fx/react-native-essentials';
All.Store // this is working
package json for the modules are like this
...
"main": "lib/index.js",
"types": "lib/index.d.ts",
...
any ideas why it behave like this?
the repository is at https://github.com/deckyfx/react-native-essentials/example
Should be able to destructure modules like how react library does
react, {useState} from "react"
CodePudding user response:
Hey not sure but i think its happenig because import { Store } from '@decky.fx/react-native-essentials'
is looking for store
in the react-native-essentials
but its not in that file its in the sub-folder of it react-native-essentials/lib/index
not in the root and so that's why you not able to destructure it from the react-native-essentials
and as for why this is working import All from '@decky.fx/react-native-essentials';
its because you importing everything from the file even its subfiles/folders .
And in this case react, {useState} from "react"
react have everything in the "react" file so that's why this works import{useSatte} from react