Can a stateless functional component have more parameters?


#1

Question

In the context of this exercise, can a stateless functional component have more parameters, other than props and state?

Answer

No, stateless functional components in React can only accept props and state as optional parameters. As a result, you cannot do something like the following, which adds other parameters other than props or state,

export const MyComponentClass = (props, param2, param3) => {
  return ...
}

If you need to pass any values to the component, you should always do so by passing them as props, without the need for adding other parameters.


FAQ: Stateless Functional Components - Stateless Functional Components and Props