1

How can i fix this error:

input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`

Here is my code snippet:

import "./styles.css";

export default function App() {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <input>Start editing to see some magic happen!</input>
    </div>
  );
}

1 Answer 1

3

That's happening because an input should be a single self closed tag. If you want some descriptive text use a label or a placeholder like so :

function App() {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <input
        placeholder = "Start editing to see some magic happen!"
      />
    </div>
  );
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.