A custom React hook generating crypting text effect.
Live demo: https://codesandbox.io/s/use-dencrypt-effect-7td0f.
npm install --save use-dencrypt-effect
import * as React from "react";
import { useDencrypt } from "use-dencrypt-effect";
const Example = () => {
const [value, setValue] = useDencrypt("initialValue");
return <div onClick={() => setValue("newValue")}>{value}</div>;
};
Returns a tuple [value, setValue]
consisting of an actual value and a method to set a new value. Just like useState()
hook.
Type: string
Result of the animation.
Sets a value and starts new animation.
Returns a promise which is resolved when animation for newValue
ends.
Type: string
A value used for next animation.
Type: string
Optional value that is returned immediately.
Type: Object
All parameters are optional.
Type: string
Default: -./^*!}<~$012345abcdef
Characters used for the effect. Picked by random.
Type: number
Default: 50
Number of miliseconds it takes for every animation step (one character).
See ./src/examples
directory.
const Example = () => {
const [value, setValue] = useDencrypt({ chars: "_" });
// ...