v2.0.0
npm i @uiw/[email protected]
- 💄 chore: update renovate.json f2434a3 @jaywcjlove
- 📖 doc: Update README.md 879e8ed @jaywcjlove
- 📄 Update LICENSE a75188d @jaywcjlove
- 💢 ci: update lintstaged config. 7b9e5d8 @jaywcjlove
- 🌟 feat(Case): add
as
props & refactor code. (#45) 0cfc8b8 @jaywcjlove
Defaults to specifying a wrapped HTML Element.
import React, { useState, Fragment } from 'react';
import { Switch, Case, Default } from '@uiw/react-only-when/switch'
export default function App() {
const [age, setAge] = useState(19)
return (
<Fragment>
<input type="range" onChange={(evn) => setAge(Number(evn.target.value))} /> {age}
<br />
<Switch>
<Case as="span" condition={age < 6}>Preschool</Case>
<Case as="em" condition={age >= 6 && age < 18}>Primary school</Case>
<Case as="div" condition={age >= 18 && age < 60}>Went to college</Case>
<Default as="p">you graduated</Default>
</Switch>
</Fragment>
);
}