Category : use-effect

Why when I click the button to close the sticky element, it becomes sticky again on scroll as if I didn’t remove the scroll eventListener? export default function MyComponent(props) { const [sticky, setSticky] = useState(false) const [hidden, setHidden] = useState(false) const handler = () => { setSticky(window.scrollY > 700) } const closeSticky = () => ..

Read more

I saw in the ReactJS docs that the dependency array in useEffect(fn, []) is optional, and not supplying it should be the same as supplying an empty array. However, if I have the code as on: https://codesandbox.io/s/trusting-sunset-h6ip9?file=/src/Count.js useEffect(() => { console.log("SETTING INTERVAL"); setInterval(() => { console.log("NOW", Date.now() / 1000); setDuration(Date.now() – startTime); }, 1000); }, ..

Read more

Firstly, I appreciate my explanation might not be the most accurate. TL;DR: the last setAllSdksInfo(objCopy) won’t work at the end of the code, while console.log just before it will print what should have been set. I believe it’s due to the asynchronous calls I’m making. I’m working on an app that compare SDKS (their churn ..

Read more

An example of this is a table with a view Link. The component which has the table is either navigated to in this manner <tbody> <tr> <td> <Link to={`/loan-requests/${loanRequest.id}/details`}> <Button size="sm" variant="outline-primary"> View </Button> </Link> </td> </tr> </tbody> and useParams and useEffect will be used to fetch the data and display or it’s done this ..

Read more

I’ve been working on a react app. I’ve added feature of filtering data. Data is being filtered on backend. So when a users sends a filter, filter is via useEffect sent to the backend URL, and retrieves data that backend provides it. Now on the backend everything works fine, but in the frontend I’ve been ..

Read more