use-dencrypt-effect
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Dencrypt example

use-dencrypt-effect

NPM Open in Visual Studio Code

A custom React hook generating crypting text effect.

Live demo: https://codesandbox.io/s/use-dencrypt-effect-7td0f.

Install

npm install --save use-dencrypt-effect

Usage

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>;
};

API

useDencrypt(initialValue?, options?)

Returns a tuple [value, setValue] consisting of an actual value and a method to set a new value. Just like useState() hook.

value

Type: string

Result of the animation.

setValue(newValue)

Sets a value and starts new animation.

Returns a promise which is resolved when animation for newValue ends.

newValue

Type: string

A value used for next animation.

initialValue

Type: string

Optional value that is returned immediately.

options

Type: Object

All parameters are optional.

chars

Type: string
Default: -./^*!}<~$012345abcdef

Characters used for the effect. Picked by random.

interval

Type: number
Default: 50

Number of miliseconds it takes for every animation step (one character).

Examples

See ./src/examples directory.

One character

const Example = () => {
  const [value, setValue] = useDencrypt({ chars: "_" });

  // ...

Run effect on hover

Live Example | Source Code

Readme

Keywords

none

Package Sidebar

Install

npm i use-dencrypt-effect

Weekly Downloads

61

Version

2.0.0

License

MIT

Unpacked Size

7.88 kB

Total Files

7

Last publish

Collaborators

  • craz