1

I want to add parameter to my callback function:

parent(here call callback function with additional parameter passed from child) <- child (here add parameter) <- child

parent:

const forwardToOrder = (TService, currentNote, orderRefNumber) => {
console.log(orderRefNumber) // IS UNDEFINED!!!
}


return (
 <DetailsSection>
                            <ReferenceNumberDetails
                                currentNote={currentNote}
                                forwardToOrder={() => forwardToOrder(TService, currentNote)}
                                labels={labels}
                            />

Child:

function ReferenceNumberDetails({ labels, currentNote, forwardToOrder }) {
    if (anyNumberExists(currentNote)) {
        return (
            <NumbersWrapper>
                <OrderNumber
//HERE I WANT TO PASS SOME PARAMETER TO BE WRITTEN BY PARENT
                    forwardToOrder={() => forwardToOrder(currentNote?.freight_order?.order_reference_number)}
                    labels={labels}
                    orderReferenceNumber={currentNote?.freight_order?.order_reference_number}
                />

1 Answer 1

3

You just update like this:

forwardToOrder={(orderRefNumber) => forwardToOrder(TService, currentNote, orderRefNumber)}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.