braisc / react-text-typist Goto Github PK
View Code? Open in Web Editor NEWReact component that simulates human typing on a keyboard.
Home Page: https://www.npmjs.com/package/react-text-typist
React component that simulates human typing on a keyboard.
Home Page: https://www.npmjs.com/package/react-text-typist
How to stop in the middle, display all content?
The latest version doesn't work with React 18, but I found that version 1.1.0 works fine.
https://codesandbox.io/s/react-text-typist-forked-lmzke0
I need a way to detect when Typer has finished typing.
In my app, I would like to disable the "Request" button until Typist finishes typing to prevent spam clicking. How can I do that?
Couple of ways I thought I might be implemented (but since its not supported in the package yet) are as follows
<Typer
sentences={[output]}
startDelay={0}
typingSpeed={7}
pauseTime={250}
cursorColor="black"
showCursor={true}
hideCursorOnFinish={true}
loop={false}
onEvent={(event) => {
if (event === "startTyping") {
setTyping(true);
} else if (event === "finishTyping") {
setTyping(false);
}
}}
/>
or
import Typer, { TyperEvent } from "react-text-typist";
<Typer
sentences={[output]}
startDelay={0}
typingSpeed={7}
pauseTime={250}
cursorColor="black"
showCursor={true}
hideCursorOnFinish={true}
loop={false}
onTyped={() => setTyping(true)}
onFinishedTyping={() => setTyping(false)}
/>
Please let me know if there is a way to do this already.
Thank you
Thanks for putting this together.
You probably need to clear out all setTimeout
handlers on component unmount, otherwise, you most likely will get the memory leak warning.
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
Please let me know if I need to submit a PR.
Firstly, love the library. Small and simple, it's exactly what I was looking for.
Just wanted to point out a small issue with the readme that caught me off guard, it refers to "writeSpeed" which it looks like you have since renamed to typingSpeed.
Thanks for the hard work!
I was just testing out this package and the 1.1.4 seems to have a bug with the typing speed? I re-installed version 1.1.0 and it worked fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.