While creating a component in Reactjs with input fields error occurs
Error: Parse Error: Line 47: Expected corresponding JSX closing tag for input at http://localhost/chat-react/src/script.js:47:20 </div>
var Main = React.createClass({
render: function() {
return (
<div className="card-action">
<i class="mdi-action-account-circle prefix"></i>
<input id="icon_prefix" type="text" class="validate">
</div>
);
}
});
You need to close the input element with a />
at the end.
<input id="icon_prefix" type="text" class="validate" />
This error also happens if you have got the order of your components wrong.
Example: this wrong:
<ComponentA>
<ComponentB>
</ComponentA>
</ComponentB>
correct way:
<ComponentA>
<ComponentB>
</ComponentB>
</ComponentA>
You have to close all tags like , etc for this to not show.
It happens when we do not close a html tag.
Make sure all the html tags are closed.
In my case it was the <br>
tag. It should be <br />
.
Try temporarily removing piece of code until you found which html tag closing is missing.
来源:https://stackoverflow.com/questions/30852751/expected-corresponding-jsx-closing-tag-for-input-reactjs