How to get value of updated state immediatly in useEffect

In the following I am updating the value of a state and then trying to use it inside useEffect only but cannot get the value of the updated state can anyone help me regarding how can i get updated state immediately inside useEffect only

Thank you

    useEffect(() => {
                dispatch(setSecondaryInvName(barcodeData))
                console.log("secondaryInventoryName == ", secondaryInventoryName)
            }
    })