Skip to main content

declare FC with hooks

!snippet signature for FC with Hook

function _MyComponent(props) {
const [value, setValue] = useState(initValue);
const [state, dispatch] = useReducer(reducer, initState);

useEffect(()=>{
// Perform side effect
};

return (
// Return some UI withs props
// ... and value & state from hooks
);
};

return(...JSX)

to return some UI from FC (typically described using JSX)

References