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:
- 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)