I'm trying to show a 'tick' next to my input when it contains at least 1 character to show a required field as being valid. The issue I have is that currently when I console.log(textEntered) each time the field changes I receive an object containing all the typed letters instead of a complete string. If I typed in 'hello' for example the log looks this (ignore the undefined):
Here is my Redux Field Component:
handleInput = (textEntered) => {
console.log(textEntered);
this.setState({ textEntered }, () => {
if (this.state.textEntered.length) {
this.setState({ completed: true });
} else {
this.setState({ completed: false });
}
});
}
render() {
return (
<Field
name={this.props.placeholderText}
component={TextInput}
onChange={this.handleInput}
/>
);
}
const TextInput = (field) => {
return (
<div className="drill-creation-input">
<input
{...field.input}
type="input"
onChange={e => field.input.onChange(e.target.value)}
/>
<label htmlFor={field.input.name}>
<span>{field.input.name}</span>
</label>
</div>
);
};
