mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
## Summary This fixes an issue with url encoding in the flyout. Turns out that `rison` does not produce url safe strings by default. |
||
---|---|---|
.. | ||
index.test.ts | ||
index.ts | ||
jest.config.js | ||
kibana.jsonc | ||
package.json | ||
README.md | ||
tsconfig.json |
@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)