Pass a state from one class to another class in REACT JS.

github logo ・1 min read

Hello, I need to pass a state from one class to another class.

Can I do it with a callback?

You help me?

class SearchNav extends Component {
constructor(props) {
this.state = {
q: '',
param: {},
getData: []

getDataSearch = () => {
fetch(url + ${this.state.q})
.then(res => res.json())
.then(data => {
this.setState({ getData: data.hits });
.catch(Error => {
I need pass state =>'getData' to other class.

twitter logo DISCUSS
Classic DEV Post from May 13

What cool ideas have you seen for integrating new team members?

I came across this tweet from a couple days ago and it really struck a chord with...

CristianCuartas profile image
In the process of learning