use-tweaks
use-tweaks copied to clipboard
Adds set and get initial tweaks data from the url hash
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 :)