Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We have an input field and a button with the value "Text". I just want to append the input field with the button's value by onClick.

What I have tried:

JavaScript
function Screen() {
  return <input id="calc" type="text" name="answer"></input>;
}

function Button() {
  return (
    <button
      onClick={() => {
        //What to write here to append "calc"?
      }}
    >
      Text
    </button>
  );
}

function App() {
  return (
    <div>
      <Screen />
      <Button />
    </div>
  );
}

export default App;
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900