use-tweaks icon indicating copy to clipboard operation
use-tweaks copied to clipboard

Adds set and get initial tweaks data from the url hash

Open emmelleppi opened this issue 5 years ago • 0 comments

I added a couple of methods in utils.ts to set and get the initial schema values, based on the url hash

How to use it

  const { speed, factor } = useTweaks({
    speed: 1,
    factor: { value: 1, min: 10, max: 100 },
  }, { setGetFromUrl: true });

or

  const { speed } = useTweaks('Example', { speed: 1 }, { setGetFromUrl: true } )

If you set the setGetFromUrl value to true in the settings, the values are automatically set in the hash of the url when the changes occur.

When the component is mounted, the schema passed to the useTweaks hook is modified with the corresponding values found in the hash.

It is far from perfect and some TS types will certainly need to be fixed :)

emmelleppi avatar Nov 04 '20 18:11 emmelleppi