// 1) imports
import * as React from 'react'
;
// ...
// 2) component props (always named IProps)
interface IProps {
// ...
}
// 2) (optional) constants
const SOME_VALUE = 1
;
// ...
// 3) default export of main component
export default function ComponentName({
prop1,
prop2 = 'default value',
}: IProps) {
// 3.1) Hook
s
// 3.2) Guard clauses
if (someCondition) {
return null
;
}
if (someOtherCondiation) {
return
;
}
// 3.3) The happy path of the component
return
My component
;
}
// 4) Everything else, like helper functions, types, custom hooks, sub components