im trying to get the params from screen A in screen B, but is always throwing error, this is the way im doing it:
go = (songs) => {
this.props?.navigation.navigate("Artists_Song", {hola: "hola"});
}
<TouchableOpacity onPress = {() => this.go(songs)}>
<View style = {{
backgroundColor: "yellow",
width: Dimensions.get("window").width * 0.48,
marginBottom: 20,
marginLeft: 5,
alignItems: "center"}}
key = {artist}>
<Image source = {require("../assets/default_image.jpg")} style={{ width: Dimensions.get("window").width * 0.48, height: 100}}></Image>
<Text style = {{fontSize: 20, textAlign: "center"}}>
{
(artist.length > 15) ?
artist.substring(0,13).padEnd(15,".")
: artist
}
</Text>
</View>
</TouchableOpacity>
and in Artists_Song:
class Artists_Song extends React.Component {
render() {
return(
<>
<Artist_Song {...this.props}></Artist_Song>
</>
)
}
and in the final component where it should be printed:
componentDidMount() {
const songs = this.props.route.params;
console.log(songs);
}
render() {
return (
<>
<Text>Hola</Text>
</>
)
}
also tried with:
this.props.route.params.hola
this.props.navigation.route.params