"scripts": {
// stock
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
//custom
"test": "vitest", // runs all unit tests in src/test directory
"clean": "rm -rf node_modules package-lock.json && npm install", // clean install
"gc": "bash scripts/gc.sh $1" // creates component in src/components directory
}
Located in src/components/vite
- Anchor
- Button
- Container
- Text
Located in src/components/
// before
{
condition? <ComponentA/>: <ComponentB/>
}
// after
<RenderIf condition={condition} fallback={<ComponentB/>}>
<ComponentA/>
</RenderIf>
<!-- before -->
<br/>
<br/>
<br/>
...
// after
<Break num={3} />
const [count, increment, decrement, reset] = useCount() // default value is 0
const [active, toggle] = useToggle() // default value is false
const {
arr,
pushBack,
pushFront,
insert,
popBack,
popFront,
remove,
clear,
reset,
sort
} = useArray<E>() // default value is blank array
const rand = useRandom<string>(["msi", "asus", "gigabyte", "asrock"])
const publish = usePublisher()
...
<button onClick = {() =>publish<E>("EVENT_NAME", DATA)}>click me</button>
useSubscriber<E>("EVENT_NAME", (eventData:E) =>{
// perform action on eventData
})
Located in src/helper/functions
-
optionals
avoid undefined/null errors by wrapping possibly undefined/null values in param and returning a default valueoptional<E>
=> default value requiredoptionalAny
=> default value requiredoptionalObject
=> blank objectoptionalArray<E>
=> blank arrayoptionalNumber
=> 1optionalBoolean
=> trueoptionalString
=> blank string
-
updateState<E>
used for updating complex states through reducers via key-value setting -
blankClick
click events w/ no effect -
sorting criteria
used for sorting arrays//ascending arr.sort(ascending) // descending arr.sort(descending)