Lint and compiler
component-hook-factories
Prefer module-level component and hook definitions to factories that construct nested definitions. Pass varying configuration as props or hook arguments.
Formal Syntax & Structure
react syntaxreact
react-hooks/component-hook-factoriesWorking Example
Example Snippetreact
import {useState} from 'react';function useCount(initial){return useState(initial)}export default function App(){const [n,setN]=useCount(2);return <button onClick={()=>setN(n+1)}>{n}</button>}