kibana/packages/kbn-url-state
Luke G 3390d8c54a
[Security Solution] fix broken encoding for the expandable flyout values (#172603)
## Summary

This fixes an issue with url encoding in the flyout. Turns out that
`rison` does not produce url safe strings by default.
2023-12-06 11:31:00 -06:00
..
index.test.ts [Security Solution] fix broken encoding for the expandable flyout values (#172603) 2023-12-06 11:31:00 -06:00
index.ts [Security Solution] fix broken encoding for the expandable flyout values (#172603) 2023-12-06 11:31:00 -06:00
jest.config.js [Security Solution] Store expandable flyout state in the url (#154703) 2023-04-21 15:45:37 -05:00
kibana.jsonc [Security Solution] Store expandable flyout state in the url (#154703) 2023-04-21 15:45:37 -05:00
package.json [Security Solution] Store expandable flyout state in the url (#154703) 2023-04-21 15:45:37 -05:00
README.md [Security Solution] [Flyout] drive flyout state with url or memory + support back button navigation from timelines (#169661) 2023-11-30 14:51:55 +01:00
tsconfig.json [Security Solution] Store expandable flyout state in the url (#154703) 2023-04-21 15:45:37 -05:00

@kbn/url-state - utils for syncing state to URL

This package provides a React hook called useUrlState that can be used to synchronize state to the URL. This can be useful when you want to make a portion of state shareable.

The state is grouped under a namespace, to avoid collisions. See the example url below for how it would look like.

Example usage:

import React, { useState } from 'react';
import { useUrlState } from '@kbn/url-state';

function MyComponent() {
  const [name, setName] = useUrlState<number>('namespace','name');

  const handleClick = () => {
    setName('John Doe')
  };

  return (
    <div>
      <p>Name: {name}</p>
      <button onClick={handleClick}>Set name</button>
    </div>
  );
}

The resulting URL will look like this:

http://localhost:5601/?namespace=(name:John%20Doe)