Req. IDE-241101: React Component (ver. 1)
There are two ways of defining a React component:
-
functional component: A function is a React component, iff
-
its return type is React.Element
-
the function has at least one parameter. This first parameter is considered as the
props
property. The type of the first parameter only has public fields (or methods defined by Object). The fields may be defined as optional.
-
-
class component: A class is a React component, iff
-
it extends
React.Component
. -
the type parameters must be structural types.
-
The first parameter defines the
props
type, it must only define public fields (or methods defined by Object) -
The second parameter defines the
state
type, it must only define public fields (or methods defined by Object)
-
-
In both cases, the name must be capitalized (i.e., start with an upper case letter).