'Error says "Import in body of module; reorder to top import/first"
enter image description hereI don't know why I'm getting these error called "Import in body of module; reorder to top import/first" although I have written the code on correct sequence.[Error ][1]
import { useState, useEffect } from 'react';
const SCROLL_UP = 'up';
const SCROLL_DOWN = 'down';
const useScrollDirection = ({ initialDirection, thresholdPixels, off } = {}) => { const [scrollDir, setScrollDir] = useState(initialDirection);
Solution 1:[1]
You should check that only your import statements are at the top of the file.
then place the constants in the function.
const useScrollDirection = ({ initialDirection, thresholdPixels, off } = {}) => {
const SCROLL_UP = 'up';
const SCROLL_DOWN = 'down';
const [scrollDir, setScrollDir] = useState(initialDirection);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DharmanBot |
