Skip to content
Advertisement

Tag: react-hooks

React Hook – multiple “useEffect” fires at componentDidMount

I’m using multiple useEffect hooks to perform the componentDidMount and componentDidUpdate functionalities, however, looks like when component loads, all my useEffect fires initially… when my component mounts, I see all those console log there How could I only let my first useEffect fires, but the other three fires when the dependency changes only? Answer useEffect is not a direct replacement

How to prevent useCallback from triggering when using with useEffect (and comply with eslint-plugin-react-hooks)?

I have a use-case where a page have to call the same fetch function on first render and on button click. The code is similar to the below (ref: https://stackblitz.com/edit/stackoverflow-question-bink-62951987?file=index.tsx): The problem for me is the fetch function always triggers on any input changed because eslint-plugin-react-hooks forces me to declare all dependencies (ex: selected state) in the useCallback hook. And

TypeError: (0 , _react.useEffect) is not a function

when in the development environment, my app works just fine. When in the production environment it crashes with the error: Uncaught TypeError: (0 , _react.useEffect) is not a function It happens in a file I created where I import React and useEffect like so: adding a console.log just below this line confirms that useEffect is indeed undefined when in production

My program is ‘skipping’ a fetch request, React.js

Its really weird. The first fetch I do works appropriately, but when doing the second fetch in my handleSubmit() method it sort of ‘skips’ it. It goes on, never enters the .then statements, doesn’t print an error. Ive tried with other APIs, but honestly it should work fine since the first take is almost identical and it worked. Ive tried

Advertisement