Categories
React Answers

How to Fix the ‘No Restricted globals’ ESLint Error When Developing a React App?

Spread the love

Sometimes, we may run into the ‘No restricted globals’ ESLint Error when developing a React app.

In this article, we’ll look at how to fix the ‘No restricted globals’ ESLint Error when developing a React app.

Fix the ‘No Restricted globals’ ESLint Error When Developing a React App

To fix the ‘No restricted globals’ ESLint Error when developing a React app, we can add the // eslint-disable-next-line no-restricted-globals comment before the code that is causing the error.

But the better solution is to put window before the variable that causes the error.

For instance, instead of writing location, we write window.location.

Conclusion

To fix the ‘No restricted globals’ ESLint Error when developing a React app, we can add the // eslint-disable-next-line no-restricted-globals comment before the code that is causing the error.

But the better solution is to put window before the variable that causes the error.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *