React Native Basics
state
, and props
. When you're building a React Native app, you'll be making new components a lot. Anything you see on the screen is some sort of component.
Props
Most components can be customized when they are created, with different parameters. These creation parameters are called props.
Your own components can also use props
. This lets you make a single component that is used in many different places in your app, with slightly different properties in each place. Refer to props.{NAME}
in your functional components or this.props.{NAME}
in your class components.
State
Unlike props that are read-only and should not be modified, the state
allows React components to change their output over time in response to user actions, network responses and anything else.
What's the difference between state and props in React?
In a React component, the props are the variables that we pass from a parent component to a child component. Similarly, the state are also variables, with the difference that they are not passed as parameters, but rather that the component initializes and manages them internally.
Comments
Post a Comment