Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Need Help - using a ref inside of useEffect
Post Flair (click to view more posts with a particular flair)
Post Body

my Goal: Is to create a simple effect that prints out a string one letter at a time.

example: string = "TEXT". it should print T E X T

Whats currently being printed is: T X T undefined

my code: ```

const [placeholder, setPlaceholder] = useState('');
const
string = 'TEXT',
index = useRef(0);
useEffect(() => {
function showChar() {
setPlaceholder(prev => prev string[index.current]);
console.log(index.current)
index.current ;
}
if (index.current < string.length) {
let addChar = setInterval(showChar, 500);
return () => clearInterval(addChar);
}
}, [placeholder]);
return (
<div>
{placeholder}
</div>
)
}
export default App;

Author
Account Strength
60%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
14
Link Karma
1
Comment Karma
13
Profile updated: 4 days ago
Posts updated: 4 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago