Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/TypeWriter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class TypeWriter extends React.Component {
const active = this.props.typing;

if (active > 0 && next < 0) {
clearInterval(this._timeoutId);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition block here causes setting of visibleChars state to fire twice along with the _handleTimeout handler. So, clearing _handleTimeout is necessary.

this.setState({
visibleChars: this.state.visibleChars - 1
});
} else if (active <= 0 && next > 0) {
clearInterval(this._timeoutId);
this.setState({
visibleChars: this.state.visibleChars + 1
});
Expand Down Expand Up @@ -103,7 +105,7 @@ class TypeWriter extends React.Component {
} = this.state;
const container = <span {...props}>{children}</span>;
const hideStyle = fixed ? {visibility: 'hidden'} : {display: 'none'};

return styleComponentSubstring(container, hideStyle, visibleChars);
}

Expand Down