Skip to content Skip to sidebar Skip to footer

React Redux Passing Parameters Via Functions From Child Components To Parent

I asked a question on this and I believe Dennis who answered the question gave the answer I thought was correct. I cant figure out how to pass variables back to the parent function

Solution 1:

"How do you set variables in the "child of a child component" and move them through to the "HandleSortDirection" function."

You are already doing this but you have a typo.

values.query = values.query || ''

This line is erroring because values is equal to 'Descending'. You are passing in a string here from your child of child component, and it is being passed up the chain of callbacks til it gets here.

Remove that line and replace it with const direction = values; and then pass direction in place of sortDirection, in searchParams.

Post a Comment for "React Redux Passing Parameters Via Functions From Child Components To Parent"