I have a React Component such as :
function callback(params){..
// I need to use this.setstate but this callback function is called
// from other component. How
You could separate this shared function, leaving it outside the components, then use bind
:
function callback(params){
this.setState({ works: true });
}
class RespProperties extends Component {
state = { works: false }
...
render = () =>
// ^ here we use .bind(this) to... well...
// bind `this` so we can use it in the function xD
}
class SomeOtherComponent extends Component {
state = { works: false }
...
render = () =>
}