kibana/packages/kbn-react-hooks
Luke Elmers b6287708f6
Adds AGPL 3.0 license (#192025)
Updates files outside of x-pack to be triple-licensed under Elastic
License 2.0, AGPL 3.0, or SSPL 1.0.
2024-09-06 19:02:41 -06:00
..
src/use_boolean Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
index.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
jest.config.js Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
kibana.jsonc
package.json Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
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>
  );
}