Sunday, April 22, 2018

React Function vs Class Component




React has 2 Components

Function Component:
  • Simplest form of react component
  • It receives an object of properties and returns JSX (which looks like html)




Class Component 
  • More featured way to define a react component
  • Apart from props it also has an input known as state. This private internal state is what gives react reactive nature
  • When class component changes react would automatically re render that component
  • It can only change the internal state and not props

 Note:State can be changed however props have all the fixed values

No comments:

Post a Comment