3

I am trying to render the following JSX code. When I add the 'Yes' and 'No' text to complement the radio buttons, I get the following error...

 <tr>
    <td>Do you want the questions displayed in a random order?</td>
    <td><input type="radio" name="random">Yes</input></td>
    <td><input type="radio" name="random">No</input></td>
 </tr>

Error: input is a void element tag and must neither have children nor use dangerouslySetInnerHTML.

What am I doing wrong?

2
  • 1
    As a side note, the <table> element is used to represent tabular data. What you have here isn't tabular data. Commented Nov 17, 2016 at 16:39
  • I'm just trying to get a bunch of questions lined up in rows and columns for text questions and then inputs. Would you recommend using a bunch of div tags in the place of a table, or some other method? Commented Nov 17, 2016 at 19:21

1 Answer 1

3

Use label

<label for="yes">Yes</label>
<input type="radio" id="yes" name="random"/>
Sign up to request clarification or add additional context in comments.

2 Comments

using a label works, but I get the following warning: "warning.js?0260:36 Warning: Unknown DOM property for. Did you mean htmlFor?"
This sheds some light on the issue, in case anyone cares. Apparently, the 'for' keyword is a no-no for the React DOM... stackoverflow.com/questions/22752116/react-label-element

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.