Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Facing this error "Unexpected use of 'scrollY' no-restricted-globals" in reactjs

I searched for it but did not find any good answer for this. like people saying that add scrollY:true to ESLint config file and did not tell where I could do these configuration and where the eslint config file is? Please help me.

This is my Navbar.jsx component.

const Navbar = () => {
    window.addEventListener('scroll', () => {
        if (window.scrollY > 100) {
            console.log('hello');
        }
    })
    return (
        <nav className='w-full py-3 flex justify-between items-center fixed top-0 z-50 nav' >
            <div>Hello</div>
        </nav >
    );
}

export default Navbar;```



[![The error which my terminal is displaying][1]][1]


  [1]: https://i.stack.imgur.com/ptSen.png

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In that case you have to create an eslint configuration file in the project’s root folder, if not already present. You can create it by simply creating an json file and naming it

.eslintrc.json

"globals": {
    "scrollY": true
}

Here’s the official link to understand – ESLink Docs – Specifying Globals

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading