ktools-r
v0.0.22
Published
Kazte's utilities tools for react
Downloads
61
Readme
Description
A collection of react tools that I use in my projects. I decided to make this package to make my life easier and to help other developers. This package is still in development and I will add more tools in the future.
I use tailwindcss in my projects, so I decided to use it in this package too. If you don't use tailwindcss, feel free to open an pull request to add support for other css frameworks.
Dependencies
Installation
npm install ktools-r
# or
yarn add ktools-r
# or
pnpm add ktools-r
Usage
Switch
import { Switch } from 'ktools-r'
enum APP_STATE {
CASE_1,
CASE_2,
NONE,
}
function App() {
const [appState, setAppState] = useState(APP_STATE.CASE_1)
return (
<Switch>
<Switch.Case condition={appState === APP_STATE.CASE_1}>
<div>
<h1>Case 1</h1>
</div>
</Switch.Case>
<Switch.Case condition={appState === APP_STATE.CASE_2}>
<div>
<h1>Case 2</h1>
</div>
</Switch.Case>
{/* ... */}
{/* As many cases as you want */}
{/* ... */}
<Switch.Default>
<div>
<h1>Default</h1>
</div>
</Switch.Default>
</Switch>
)
}
Loader