I have a component UsernameInput, which is managed via redux store.
I want to get input value when onCut event triggered.
import React from 'react'
import connect from 'react-redux'
import {validateUsername} from '../actions'
const UsernameInput = ({username, validateUsername}) => {
return (
<div className="form-group">
<input type="text" className="form-control"
onChange={e => validateUsername(e.target.value)}
onPaste={e => validateUsername(e.clibboardData.getData('Text'))}
onCut={e => validateUsername(e.currentTarget.value)}
defaultValue={username}
/>
</div>
);
}
export default connect((state) => state.validateUsername, {validateUsername})(UsernameInput);
That is if the value of input is "blablabla", and after cutting the whole text validateUsername function should be called with empty string, and if the half of the input was cut, then it should be called with parameter like "blab".
onCut e.currentTarget.value is returning the value of the input field before cut, but I want it to return the actual input value.
How to do it?