Skip to content
Advertisement

Why I am getting cross origin error in React?

I am quite new in React. I have build an event scheduler web app but it’s only working in my browser if I try it to different browsers or someone else system it gives me this error:

A cross-origin error was thrown. React doesn’t have access to the actual error object in development.

I am trying to figure out but all I can understood it’s happening because I am giving default values in state if local storage in undefined. Here is my complete code.

This is the component that is getting the error:

JavaScript

Advertisement

Answer

You’re trying to parse an object. JSON.parse expects a JSON but you’re passing an object.

You could check the sandbox here

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement