mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
Updates files outside of x-pack to be triple-licensed under Elastic License 2.0, AGPL 3.0, or SSPL 1.0. |
||
---|---|---|
.. | ||
src/use_boolean | ||
index.ts | ||
jest.config.js | ||
kibana.jsonc | ||
package.json | ||
README.md | ||
tsconfig.json |
@kbn/react-hooks
A utility package, @kbn/react-hooks
, provides custom react hooks for simple abstractions.
Custom Hooks
useBoolean
Simplify handling boolean value with predefined handlers.
function App() {
const [value, { on, off, toggle }] = useBoolean();
return (
<div>
<EuiText>
The current value is <strong>{value.toString().toUpperCase()}</strong>
</EuiText>
<EuiFlexGroup>
<EuiButton onClick={on}>On</EuiButton>
<EuiButton onClick={off}>Off</EuiButton>
<EuiButton onClick={toggle}>Toggle</EuiButton>
</EuiFlexGroup>
</div>
);
}