https://github.com/yyz945947732/react-switch-case-render
Switch-case React component to render nested components.
https://github.com/yyz945947732/react-switch-case-render
react react-component react-condition react-switch-case
Last synced: about 1 month ago
JSON representation
Switch-case React component to render nested components.
- Host: GitHub
- URL: https://github.com/yyz945947732/react-switch-case-render
- Owner: yyz945947732
- License: mit
- Created: 2023-09-14T08:23:33.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-15T03:51:22.000Z (over 2 years ago)
- Last Synced: 2025-10-27T09:39:36.883Z (7 months ago)
- Topics: react, react-component, react-condition, react-switch-case
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/react-switch-case-render
- Size: 300 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-switch-case-render
> Switch-case React component to render nested components.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
npm install --save react-switch-case-render
```
## Usage
```ts
import { Switch, Case, Default } from 'react-switch-case-render';
function Example({ expression }) {
const type = 'show';
return (
show
add
edit
nothing to show.
);
}
```
### API
#### \
The `` components provide an expression, matching the expression's value against a series of `` components, and render `` children after the first `` with a matching value.
| Prop | Type |
| ---------- | ------------------------------------ |
| expression | string/number/boolean/null/undefined |
| children | React.ReactNode |
#### \
provide an value used to match against expression. if the expression matches the value, the `children` will be render.
| Prop | Type |
| -------- | ------------------------------------ |
| value | string/number/boolean/null/undefined |
| children | React.ReactNode |
#### \
if the value of expression doesn't match any of the `` value, the `children` will be render.
| Prop | Type |
| -------- | --------------- |
| children | React.ReactNode |
## LICENSE
[MIT](https://github.com/yyz945947732/react-switch-case-render/blob/master/LICENSE)