What types of values can be passed as props?

Question

In the context of this exercise, what types of values can be passed as props?

Answer

The types of values that can be passed as props are mostly the same data types that are available in JavaScript. The most common ones are as follows,

// array
[1, 2, 3]

// boolean
true

// function
function add(a, b) {
  return a + b;
}

// number
3.14

// object
var dog = {
  name: "Cookie",
  age: 8
}

// string 
"Hello world"

// symbol
Symbol('foo')
1 Like