Professional Documents
Culture Documents
04.state and Props in RN - Fixed
04.state and Props in RN - Fixed
2 State
3 Props
4 Q&A
State vs Props
State vs Props
➢There are two types of “model” data in RN Component
– Props and state Props State
➢Props
– Component's configuration
– Immutable
<Component props_name
➢State = “props_value”
– The state starts with a default value when a Component mounts
and then suffers from mutations in time (mostly generated
from user events)
– keep track of information between renderings the
component itself can create, update, and use state.
State vs Props – cont
➢Props
– For user to use view
– Read-only (user side)
– Can not be modified (user side)
➢State
– For implementing
– Change can be asynchronous
– Can be modified
State
State
➢State of a component is an
object that holds some
information that may change
over the lifetime of the
component.
– state hold information for view
Change Text (without State)
Changed?
useState() Reference: https://reactjs.org/docs/hooks-state.html
Click
Q&A