Skip to content
Discussion options

You must be logged in to vote

I would add it to the custom useOrder hook, or create another one:

const useOrderMutation = () => {
    const {data: order} = useOrder();
    const [chargeCard] = useChargeCard();

    return () => {
        chargeCard(order.orderId)
    }
}

if you change the return type to something like this, you can spread it onto a button and it will be disabled as long as you have no orderId:

return {
    onClick: () => {
        chargeCard(order.orderId)
    }
    disabled: !!order
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@blessanm86
Comment options

@TkDodo
Comment options

@TkDodo
Comment options

@blessanm86
Comment options

Answer selected by blessanm86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants