Stateless Function (Presentational Component)
#
What is Stateless Function?- Stateless function is a way to define React components as a function. Rather than as a class or via
React.createClass
. - Stateless function does not hold state; just props.
#
For examplesWithout stateless function, write a presentational component that is just renders props, and doesn't has state.
With stateless function.
With stateless function, arrow function, destructuring and implicit return.
Stateless function is great for styling as well.
Stateless function with event handlers.
Stateless function can have defined defaultProps, propTypes.
Stateless function can have defined contextTypes (when using context, it's simply passed in as the second argument).