Skip to content

tiy-tpa-fee/mini-redux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Understanding Props vs State

<Multiply a="4" b="2" />  // => 8
const multiply = (a, b) => {  // <-- Props
  const product = a * b       // <-- State
  return product
}
<Square n="4" />     // ==> 16
class Square extends Component {

   render () {
      return <Multiply a={this.props.n} b={this.props.n} />
   }
}
const square = (n) => {          // <-=  props
  const product = multiply(n, n) // <-- state
  return product
}
// multiply(4, 2)  // => 8

Props are just like parameters/arguments to a function State is like internal variables scoped to a function

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published