JSFiddle - React, Tailwind, and code Playground

by enriquerene

HTML

<div>
  <input type="text" />
</div>

React

class dependentFields extends React.Component {

	constructor(){
  	super();
    this.state = {
    	control: "",
      getOne: "",
      getTwo: ""
    }
    this.getContent = this.getContent.bind( this );
    this.updateControl = this.updateControl.bind( this );
  }
  
  updateControl( event ) {
  	 this.setState( { control: event.target.value } );
     /* this.getContent() */;
  }

	getContent() {
  	fetch( "https://viacep.com.br/ws/24900125/json" )
    .then( response => response.json() )
    .then( json => {
    	console.log( json );
      /*this.setState( {
      	getOne: json.logradouro,
        getTwo: json.localidade + " / " + json.uf
      } );*/
    } );
  }

	render(){
  this.getContent();
    return(
      <div>
        cep
        <input
          type="text"
          value={ this.state.control }
          onChange={ this.updateControl }
        />
        x
        <input
          type="text"
          value={ this.state.control }
        />
      </div>
    );
  }
  
}