简体   繁体   中英

I want to add a textbox to my React app, how would I go about this?

I am a complete beginner and I would like to add a text box -eventually I would have buttons with logic characters that would show up in the textbox as I click them).

Should this be a component? Do I make it via index.html or index.js? None?

I am quite lost and all of my attempts have led to nothing. I assume the only useful code I can provide is my index.html, so here it is. This is basically the default.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
  name="description"
  content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<title>Kirk Logic Tool</title>
  </head>
  <h1>Kirk Logic Tool</h1>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

Thank you for any responses, as a learner I really appreciate all who take the time to respond:)

You would create another JS file with a class that extends React.Component and use render(<MyComponent/>, document.getElementById('root')) . Here's an example:

 class MyComponent extends React.Component {
      
        render() {
             return <input type="text"/>
         }
    
    }

    ReactDOM.render(
      <MyComponent/>,
      document.getElementById('root')
    );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM