Navigate back to the homepage

How to force render in react native

Infinitbility
React Native
August 12th, 2021 · 1 min read
How to force render in react native

Hello Friends 👋,

Welcome To Infinitbility! ❤️

This tutorial will help you to force re-render in your react native application, here we will see how many ways to re-render components in react native and how to force re-render in react native for example.

As we know, React Native auto re-render content when any state change, any props change, or we have also an option to force update.

If your issue solves using the first ( state change ), and second ( props change) method then I will recommend don’t go with forceUpdate() method.

This is a method that is highly discouraged. Always use props & state changes to cause a new render.

But nonetheless, here is how you can do it!

1import React from 'react';
2import { View, Text, Button } from 'react-native';
3
4class App extends React.Component {
5
6 handleClick = () => {
7 // force a re-render
8 this.forceUpdate();
9 };
10
11 render() {
12 console.log('App component: render()')
13 return (
14 <>
15 <Button onClick={this.handleClick}>Say something</Button>
16 </>
17 );
18 }
19}

Thanks for reading…

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Tutorials

React Native

Categories

More articles from Infinitbility

How to get current date in react native

How to get current date in react native

React Native current date Example

August 12th, 2021 · 1 min read
How to filter array in react native

How to filter array in react native

React Native filter array Example

August 11th, 2021 · 1 min read
© 2020–2021 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]