'How to use callback of setState in some places not all via hooks

I want to set a state and sometimes I want to do something after that and sometimes not!

how can I do that with hooks?

sometimes I want to call a function or do something after setting that:

 this.setState({inputValue:'someValue'},()=>{
    //do something
    })

but sometimes not

this.setState({inputValue:'someAnotherValue'})

then I couldn't use of useEffect like this because I don't want to do something after setting that all the time:

useEffect(()=>{

    //do something 

},[inputValue])


Solution 1:[1]

useEffect(() => {
    if(inputValue == someValue){
        //do something
    }
}, [inputValue])

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 juliomalves