Terox
Terox

Reputation: 119

React-Native: Load a Screen by the click of a button

I am trying to make an App with React-Native and Expo.

The App should display a flat list which is filled with buttons. Every button is supposed to load a new screen that displays text.

The App should display a flat list filled with buttons each one leading to a seperate screen

My problem is how do I implement a button that loads a specific screen (that was not saved before as a separate file but is loaded by app.js).

I have seen tutorials on the render function but didn't know if it was the thing i am looking for.

renderfunction(buttonname){
  render(buttonname){
    return(
    <SafeAreaView>
      <Text>{buttonname}</Text>
    </SafeAreaView>
    );
  }
} 
return (
<Button
          onPress={renderfunction}
          title="Learn More"
          color="#841584"
/>
);

This is what I have put together from the different tutorials on the render function but this does't work for me and I dont know if this is the right approach to my problem.

My Question is: is the render function the right thing for my problem?

I would appreciate your help Thanks in advance

Upvotes: 1

Views: 615

Answers (1)

devkev
devkev

Reputation: 50

The render function is the right thing to use for your case. I recomend you to read the react.js document on the render function here

Does that answer your question?

If not Let me know ;)

Upvotes: 1

Related Questions