<main></main>
.valid {
  border-bottom: 1px solid green;
}

.invalid {
  border-bottom: 1px solid red;
}
class Textbox extends React.Component {
  constructor(props) {
    super(props);
    this.state = { text: props.text };
  }
  
  setText(newText) {
    this.setState({ text: newText });
  }
  
  render() {
    const initialText = this.props.text;
    const { text } = this.state;
    const cls = (text === initialText ? 'valid' : 'invalid');
    
    return (
      <input
        type='text'
        value={text}
        className={cls}
        onChange={(e) => this.setText(e.target.value)}
      />
    )
  }
}

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = { text: 'hello world' };
  }
    
  render() {
    const {text} = this.state;
    return (
      <div>
        <Textbox text={text} />
        <Textbox text={text} />
        <Textbox text={text} />
        <Textbox text={text} />        
      </div>
    );
  }
}

ReactDOM.render(<App />, document.querySelector('main'));
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/16.3.1/umd/react.development.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.3.1/umd/react-dom.development.js