132
rated 0 times
[
138]
[
6]
/ answers: 1 / hits: 19522
/ 7 Years ago, thu, may 4, 2017, 12:00:00
Im trying to implement a chartercter limit for a textArea in react js
here is my code.
state = {
chars_left: 140;
}
handleWordCount = event => {
const charCount = event.target.value.length;
const maxChar = this.state.chars_left;
const charLength = maxChar - charCount;
this.setState({ chars_left: charLength });
}
<textArea
rows={6}
type=text
maxLength=140
required
onChange={this.handleWordCount}
/>
{${this.state.chars_left}
}
I have a function that should that show how many character the user is typing and it starts at 140 but it skips tons numbers every time i type something like 130 when i type a single character
what could the problem be?
More From » reactjs