DEV Community

Chandrasekar Kuppusamy
Chandrasekar Kuppusamy

Posted on • Originally published at Medium on

Props and State in React Native

What is Props?

Props can be referred to something that can be changed dynamically in a Component (i.e Ideally, passing parameters through constructor in JAVA). Let’s discuss more on this by comparing JAVA with React Native.

Code Usage:

  1. Destination Class: (Class which receives props data)

2. Source Class: (Class which sends props data)

What is State?

State is nothing but a triggering method which is used to refresh or update values in the Component. Each time when ‘ setState ’ is called, the render() function in a Component will be called simultaneously.

Code usage:

The above code snippet creates the Button component with the initial text as “ Failure ”, and the text is replaced to “ Success ” using ‘ setState ’ function when the button is clicked or pressed.

Top comments (0)