0

I have three file ( The full project is https://github.com/EnginYilmaz/kpbduser)

  • MapScreen.js
    • FetchData.js
    • ShowData.js

I want to print a Map on FetchData and on marker click want to pass which markerkey pressed to MapScreen.js and then Query the people on index key and show data with ShowData.js but I don't know how to pass data back from FetchData.js to Parent (MapScreen.js). I illustrated my question on this image

Engin Yilmaz
  • 393
  • 1
  • 5
  • 17

1 Answers1

1

You can use props to handle data passing in react native. A basic example is shown below

export default class ParentClass extends Component {
    callbackMethod = (value) => {
        console.log('Callback is called',value);
    };

    render() {
        return <ChildView callbackMethod={this.callbackMethod} />;
    }
}



export default class ChildView extends Component {

    onPress=()=>{
        this.props.callbackMethod("Hello");
    }
    render() {
        return <Button onPress={this.onPress} />;
    }
}
Victor
  • 4,171
  • 1
  • 29
  • 37