Skip to content

Instantly share code, notes, and snippets.

@jhonsore
Created February 1, 2022 11:24
Show Gist options
  • Save jhonsore/abdf6f019fc2eb9d9cbca176777886ab to your computer and use it in GitHub Desktop.
Save jhonsore/abdf6f019fc2eb9d9cbca176777886ab to your computer and use it in GitHub Desktop.
SCC(State, Controller and Component) Pattern
import { useMemo, useState } from "react"
type TController = {
}
export const useController = () => {
const [data, setData] = useState({} as TController);
const [] = useMemo(() => {
return [];
}, [data]);
const update = (e:TController) => {
setData(e);
}
return {
state: {
data
},
actions: {
update
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment