Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react get input value on button click functional component

const input = props => {

let textInput = React.createRef();

function handleClick() {
  console.log(textInput.current.value);
}

return (
    <div>
      <input ref={textInput} placeholder="Type a message..." />
      <div onClick={handleClick} className="icon">
        <i className="fa fa-play" />
      </div>
    </div>
  )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #input #button #click #functional #component
ADD COMMENT
Topic
Name
4+5 =