@@ -21,7 +21,9 @@ const Main = ({
2121 loop = false ,
2222 pause = false ,
2323} : TypistProps ) => {
24- const [ typedChildrenArray , setTypedChildrenArray ] = useState < TypedChildren [ ] > ( [ ] ) ;
24+ const [ typedChildrenArray , setTypedChildrenArray ] = useState < TypedChildren [ ] > (
25+ [ ]
26+ ) ;
2527 const [ currentIndex , setCurrentIndex ] = useState ( - 1 ) ;
2628 const clearTimerRef = useRef ( emptyFunc ) ;
2729 const loopRef = useRef ( loop ) ;
@@ -88,18 +90,18 @@ const Main = ({
8890 const actions = getActions ( children , splitter ) ;
8991 if ( startDelay > 0 ) await timeoutPromise ( startDelay ) ;
9092 for ( const { type, payload } of actions ) {
91- if ( pause ) await pausePromise ( ) ;
93+ if ( pauseRef . current ) await pausePromise ( ) ;
9294 if ( type === 'TYPE_TOKEN' ) {
93- setCurrentIndex ( prev => prev + 1 ) ;
95+ setCurrentIndex ( ( prev ) => prev + 1 ) ;
9496 await timeoutPromise ( typingDelay ) ;
9597 } else if ( type === 'BACKSPACE' ) {
9698 let amount = payload ;
9799 while ( amount -- ) {
98- setCurrentIndex ( prev => prev + 1 ) ;
100+ setCurrentIndex ( ( prev ) => prev + 1 ) ;
99101 await timeoutPromise ( backspaceDelay ) ;
100102 }
101103 } else if ( type === 'PASTE' ) {
102- setCurrentIndex ( prev => prev + 1 ) ;
104+ setCurrentIndex ( ( prev ) => prev + 1 ) ;
103105 } else if ( type === 'DELAY' ) {
104106 await timeoutPromise ( payload ) ;
105107 }
0 commit comments