TypeError: Cannot read property 'createConfig' of undefined

Platform: ReactNative app with Typescript.

Was able to integrate and run the app with Okta, the “” component renders the button, but
keep getting TypeError after clicking on the “Login” button in the ReactNative app using the current okta versions:
@okta/okta-react-native”: “^1.4.1”,
@oktadev/schematics”: “^2.1.1”,

14:55
[Unhandled promise rejection: TypeError: Cannot read property ‘createConfig’ of undefined]

Stack trace:
node_modules/@okta/okta-react-native/index.js:31:28 in createConfig
node_modules/regenerator-runtime/runtime.js:45:39 in tryCatch
node_modules/regenerator-runtime/runtime.js:274:21 in invoke
node_modules/regenerator-runtime/runtime.js:97:20 in prototype.method
node_modules/regenerator-runtime/runtime.js:45:39 in tryCatch
node_modules/regenerator-runtime/runtime.js:135:19 in invoke
node_modules/regenerator-runtime/runtime.js:170:10 in PromiseImpl$argument_0
node_modules/promise/setimmediate/core.js:45:4 in tryCallTwo
node_modules/promise/setimmediate/core.js:200:12 in doResolve
node_modules/promise/setimmediate/core.js:66:2 in Promise

WARNING
14:56
[Unhandled promise rejection: TypeError: Cannot read property ‘signIn’ of undefined]

Stack trace:
node_modules/@okta/okta-react-native/index.js:88:22 in signIn
node_modules/regenerator-runtime/runtime.js:45:39 in tryCatch
node_modules/regenerator-runtime/runtime.js:274:21 in invoke
node_modules/regenerator-runtime/runtime.js:97:20 in prototype.method
node_modules/regenerator-runtime/runtime.js:45:39 in tryCatch
node_modules/regenerator-runtime/runtime.js:135:19 in invoke
node_modules/regenerator-runtime/runtime.js:170:10 in PromiseImpl$argument_0
node_modules/promise/setimmediate/core.js:45:4 in tryCallTwo
node_modules/promise/setimmediate/core.js:200:12 in doResolve
node_modules/promise/setimmediate/core.js:66:2 in Promise

OktaDev Schematics only supports JavaScript at this time. You can see our current templates. If you’d like to see TypeScript support added for React Native, please create an issue in the project.

Just to warn you: I’m going on vacation today and won’t be back until August. If you add the issue, I won’t be able to work on it until then.

1 Like

Thanks for your quick response!

I’ve tried to manually integrate, is that a valid option for Typescript, or it won’t work both Schematics/Manual integration?
The “Login” button was successfully rendered though, but when you click on it I guess TypeError thrown.
Since it’s referring to your deployed code under node_modules/, is there a work around?

@okta/okta-react-native’

// I also tried turning the “allowJs” to true in tsconfig file
“compilerOptions”: {
“allowJs”: true,

I haven’t tried to use TypeScript with React Native, so I’m not sure. I was able to integrate our React SDK with TypeScript so it should be possible. Using Okta with React App in Typescript

Hi,

I tried the declaration module as suggested in the thread, but getting a different TypeError instead, as shown below. Is there okta-react-native with typescript example?

There’s an example which uses react-native-app-auth library, is this recommended for ReactNative app?

// in okta.d.ts file
declare module ‘@okta/okta-react-native’

[Unhandled promise rejection: TypeError: (0 , _oktaD.signIn) is not a function]

Stack trace: http://192.168.1.9:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:179987:35 in login$ node_modules/regenerator-runtime/runtime.js:45:39 in tryCatch node_modules/regenerator-runtime/runtime.js:274:21 in invoke

The most important thing IMO is to get something working. I’ve used the react-native-app-auth library before and created the example you mentioned. We use it in JHipster’s React Native support and I think it works well. Please try it and let us know if you have any issues.