Passing a function with React Context API to child component nested deep in the tree Passing a function with React Context API to child component nested deep in the tree reactjs reactjs

Passing a function with React Context API to child component nested deep in the tree


Maybe something like that?

<Context.Provider    value={{        state: this.state,        onSortClient: this.onSortClient,    }}>    {this.props.children}</Context.Provider>

So, value.state will be your state, value.onSortClient will be your function.