From the course: React Native Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Remounting a component to reset it

Remounting a component to reset it - React Native Tutorial

From the course: React Native Essential Training

Start my 1-month free trial

Remounting a component to reset it

- [Instructor] Let's do one last feature for this game. Let's create a Play Again button once the game is won or lost. We'll start with the markup for that button. Let's place it in this area under the numbers. We can use the Button component from React Native. Here is the documentation for the Button component. We give it an onPress event and a title for that button. Let's do that. We'll place it right here under the View, Button with a title of Play Again. And we'll figure out the onPress next. But let's see how that looks. Well, you can see actually how the onPress is a required property. So let's provide an empty onPress function. Here's the button, it looks decent. So what should this button do? This button should completely reset the game, which means it has to reset the state of the game but also, it means that we have to generate a new target number. We have to generate a new set of random numbers and we…

Contents