Create Dynamically Named Custom React Components
A React element is as simple as a function that returns some valid JSX. Any function will do.
This function provides us with a React component that has a fixed name -- CustomComponent
. With the help of the displayName
property, we can create dynamically named components.
If we inspect the generated React tree, we will not see anything called <CustomComponent>
, but instead we will see our <RandomComponentName>
component.
Remember, React components need to have an uppercase name.
Last updated