Answers for "editable pre input react"

0

editable pre input react

import React, { useState } from 'react';

function Example() {
  const [url, setUrl] = useState("http://localhost:3000");

  return (
    <div>
      <input type="text" value={url} onChange={(e) => setUtl(e.target.value)} />
    </div>
  );
}
Posted by: Guest on August-25-2021
0

editable pre input react

class App extends Component {
  constructor() {
    super();
    this.state = {
      inputValue: 'http://localhost:3000'
    };
    this.handleChange = this.handleChange.bind(this);
  }

   handleChange(e){
    console.log(e.target.value);
    this.setState({inputValue: e.target.value});
  }

  render() {
    return (
      <div>
        <input type="text" value={this.state.inputValue} onChange={this.handleChange} />
      </div>
    );
  }
}
Posted by: Guest on August-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language