Next.js Discord

Discord Forum

Writing to a variable defined outside a component or hook is not allowed

Unanswered
Siberian posted this in #help-forum
Open in Discord
Avatar
SiberianOP
With the new react compiler, linter I have a few Writing to a variable defined outside a component or hook is not allowed. Consider using an effect an example of something triggering this is

  const onSomeEvent = () => {
    document.body.style.overflow = showMobileFilters ? "auto" : "hidden";
  };


What is the suggested way to solve this?

0 Replies