profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/vkurchatkin/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Vladimir Kurchatkin vkurchatkin Moscow

vkurchatkin/koa-connect 159

Use connect and express middleware in koa

vkurchatkin/function-origin 50

Get origin of a function in io.js and node.js

vkurchatkin/geojson-flow 9

GeoJSON type declarations for Flow

vkurchatkin/generator-foreach 5

forEach for generators

vkurchatkin/connect-compose 4

Compose connect middleware

vkurchatkin/iojs-ru 1

Перевод io.js на русский язык

vkurchatkin/jquery.couch 1

jquery.couch.js for bower

vkurchatkin/8bit.js 0

8Bit.js Audio Library - Write music using 8bit oscillation sounds.

issue commentfacebook/react

Feature Request - useEffect - Provide boolean values on whether dependency has changed.

@yamarco you can achieve exactly the same with this

 useEffect(() => {
    // only if name changed
  }, [name])

 useEffect(() => {
    // if name or data changed
  }, [name, data])
yamarco

comment created time in 10 days

issue commentfacebook/react

Feature Request - useEffect - Provide boolean values on whether dependency has changed.

@francoMG it does exactly the same as

useEffect(() => {
   // do something
}, [varA])
yamarco

comment created time in 12 days

issue commentfacebook/react

Feature Request - useEffect - Provide boolean values on whether dependency has changed.

  1. Well, yes. You can suppress it, if you know what you are doing
  2. That is not possible. The only way to always have access to the lates value is to trigger effect
yamarco

comment created time in 15 days

issue commentfacebook/react

Feature Request - useEffect - Provide boolean values on whether dependency has changed.

@yamarco you can access latest state like this, just don't add it to dependencies

yamarco

comment created time in 15 days

issue commentfacebook/react

Optional callback when updating state in functional components.

The thing is, even if setState had a callback, it wouldn't change anything:

 setProductionCardList(
        productionCardListCopy,
        () => {
            // new state is rendered, but productionCardList is still the same
           // it can never change for any reason, it is literally a const
        }
    };
emindotbdk

comment created time in 15 days

issue commentfacebook/react

Feature Request - useEffect - Provide boolean values on whether dependency has changed.

If you want to do something only if one dependency changes, you can just use a separate useEffect:

useEffect(() => {
    console.log('Do Something only when secondDepChanged');
  }, [secondDep])
yamarco

comment created time in 15 days

issue commentfacebook/react

React 18: useEffect calling twice inside a custom hook

This specifically is described here https://github.com/reactwg/react-18/discussions/19

hieuhani

comment created time in 2 months

issue commentfacebook/react

Bug: Number increases twice with set-Callback

Well, you shouldn't "mutate prevState directly". That's what causes the problem

Shaegi

comment created time in 2 months

issue commentfacebook/react

Bug: React StrictMode takes not updated state value

This is neither a bug nor a limitation. This block of code violates some important rules:

 if (shouldUpdate.current) {
    setValue(10);
    shouldUpdate.current = false;
  }
  1. You read a mutable value during render (ref value)
  2. You perform side effects in render (calling state setter and mutating the ref)

StrictMode is just doing its job and highlights these issues

Eliav2

comment created time in 2 months

issue commentfacebook/react

Bug: [eslint-plugin-react-hooks] Functions returning new dates should be flagged as missing dependencies

Well, getCurrentDate doesn't actually capture any local variables, hence this behaviour. What you propose would basically disable useMemo in this case (since getCurrentDate is a new reference in every render). But what should be done if new Date is used in useMemo directly?

 const currentTime = useMemo(() => {
   return new Date().toISOString(); 
 }, []);

Behaviour is exactly the same, but there is nothing you can add to dependencies.

amanmahajan7

comment created time in 2 months

issue commentfacebook/react

Bug: [eslint-plugin-react-hooks] Functions returning new dates should be flagged as missing dependencies

Should flag getCurrentDate as missing dependency

And what that dependency would be?

amanmahajan7

comment created time in 3 months