Coder Social home page Coder Social logo

Comments (9)

simoneb avatar simoneb commented on June 27, 2024

because react 18 renders twice in development mode. https://stackoverflow.com/questions/72238175/useeffect-is-running-twice-on-mount-in-react

from axios-hooks.

gremo avatar gremo commented on June 27, 2024

@simoneb not sure about that. I use for testing another hook (use-http):

const { loading, error, data } = useFetch('https://dummyjson.com/products', {}, []);

Why this hook only trigger 1 render? Two in total...

from axios-hooks.

simoneb avatar simoneb commented on June 27, 2024

can you provide a repro?

from axios-hooks.

gremo avatar gremo commented on June 27, 2024

@simoneb I really appreciate your work, and OS software in general. For me, and maybe for you, it's more than a work. So I suggest you not to close an issue after five minutes, making assumptions about other's project/setup.

Yes, I maybe a beginner in React but I'm not completely dumb.

  1. Yes, I'm using React 18 (but you didn't know)
  2. I'm not using strict mode, neither in that component nor up the tree (but you didn't know)
  3. Either way, I would have noticed already the double rendering, elsewhere in my app
  • 3 rendering using useAxios sandbox

useAxios

  • 2 rendering using useFetch sandbox

useFetch

from axios-hooks.

simoneb avatar simoneb commented on June 27, 2024

I see your point, I had assumed React 18 was the cause. I've had a look at your repro and it looks legit. This seems to be causes by an improper handling of the state of the initial request.

Would you be interested in submitting a PR to fix this?

from axios-hooks.

gremo avatar gremo commented on June 27, 2024

@simoneb thanks but I really can't, my experience with React isn't advanced yet! Hope to see a fix soon (or revert to a previous version maybe?)

from axios-hooks.

gremo avatar gremo commented on June 27, 2024

Any update @simoneb ?

from axios-hooks.

simoneb avatar simoneb commented on June 27, 2024

@gremo I didn't have a chance to look into it, but why don't you give it a go? I think it might be pretty simple. If the new state object is the same as the existing, don't change the state :)

from axios-hooks.

Paola3stefania avatar Paola3stefania commented on June 27, 2024

Hello ! For what we have been researching with @Cherrerotinoco It has to be with how the initialState its hanlded with manual false (automatic ), you can prevent this refetching error with (manual: true) while waiting for a new PR

from axios-hooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.