Component Structure
Last updated
Last updated
(, )
(, )
Notes:
Only 1 exported function per component file (the main/"exported" component)
If needing to reuse a local component/function/variable/type in another file, it should then be be moved to their own file at that time (and moved to their proper location)
Use named export (vs default export)
Use Props
as the name for exported component's interface/type
For additional local components, append "Props" to the local component name LocalComponentNameProps
Destructure top-level props within signature (vs first line destructuring)
Then, use first-line destructuring for destructuring individual top-level props when needed
When creating a utility/reusable component with an MUI component as the "base" component:
.Props
interface should extend the MUI component's native props
Destructure the sx
prop from ...props
(within the component signature/declaration)
Pass in the destructured sx
prop into the MuiComponent's sx prop after any "default" sx styling
Otherwise, passing the sx
prop to an instance of the MuiComponent will override any "default" sx
prop styling that exists