Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You can try the following:
removeLast = () => {
this.setState({ value: this.state.value.substring(0, this.state.value.length - 1)})
};
<button onClick={this.removeLast}>remove</button>
The previous State must be changed via a callback
deleted = () => {
this.setState(({value}) => {
const str = value.slice(0, -1);
return {
value: str
}
});
};
button onClick={this.deleted}>remove</button>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question