Added
A complete rewrite. Now it is possible to set initial value and/or set new value to be the same as the previous one.
API is similar to React's useState
, it returns a tuple:
import { useDencrypt } from "use-dencrypt-effect";
const Example = () => {
const [value, setValue] = useDencrypt("initial value");
return <div onClick={() => setValue("new value")}>{value}</div>;
};
It is also possible to import just core function and use it without React:
import { dencrypt } from "use-dencrypt-effect";
const setValue = dencrypt({
initialValue: "initial value",
callback: (value) => {
element.textContent = value;
},
});
Changed
- Migrated to Vite and Vitest.
Full Changelog: v1.0.2...v2.0.0