I’m doing exactly as it mentioned in this document Sign in to your SPA with Auth JS | Okta Developer
but I’m getting a TypeError: Object(…) is not a function error in the browser for this line in react
If you want to get started with React and Okta quickly, I’d suggest you using OktaDev Schematics.
npx create-react-app secure-react
cd secure-react
# Create a SPA app on Okta to get a client ID
npm install -g @angular-devkit/schematics-cli
npm i @oktadev/schematics
schematics @oktadev/schematics:add-auth
Thank you very much @mraible! That sure will help!
However, I was wondering what caused this error in the first place. Looks like none of them had this issue before. I am not sure why it wouldn’t work for me. I would be more than glad if you could help me figure out what went wrong.
I’m not sure what’s causing your issue. It’s very difficult to tell without seeing the code and having steps to reproduce. If you’re able to provide the steps to reproduce, or post your code to a GitHub repo, I’d be happy to try and diagnose the problem.
It looks like you’re using old methods from the React SDK. For example, withAuth instead of withOktaAuth. The documentation you reference uses withOktaAuth. Also, your code doesn’t have your Okta information in it. You might have better luck using one of our Okta React samples.
I followed the tutorial myself and created a pull request to show the changes I needed to make to your app to get it working.