2015-05-16 11 views
20

में अमान्य घटक तत्व मैं एक सरल हैलो विश्व उदाहरण के साथ एक प्रतिक्रिया.जेएस ट्यूटोरियल के माध्यम से जा रहा हूं। मुझे कोई कारण नहीं मिल रहा है कि निम्नलिखित क्यों काम नहीं करना चाहिए, लेकिन मुझे यह त्रुटि मिल रही है।React.JS

Uncaught Error: Invariant Violation: React.render(): Invalid component element. 

मेरे पास निम्न कोड है। ऐसा लगता है कि अगर मैं React.createElement करता हूं, लेकिन जेएसएक्स तत्वों के लिए नहीं।

<!doctype html> 
<html> 
<head> 
    <script src="https://fb.me/react-0.13.3.js"></script> 
    <script src="https://fb.me/JSXTransformer-0.13.3.js"></script> 
    <script type="text/jsx"> 
     document.body.onload = function(){ 
      console.log("shuff") 
      var HelloWorld = React.createClass({ 
       render: function(){ 
        return <div>Hello, Ian Shuff!</div>; 
       } 
      }); 

      React.render(new HelloWorld(), document.getElementById("test")) 
     } 

    </script> 
</head> 
<body> 
    <div id="test"></div> 
</body> 
</html> 

उत्तर

21

आप नहीं new HelloWorld()

React.render(<HelloWorld />, document.getElementById("test")) 

Example

jsx-in-depth

<HelloWorld /> रेंडर करने के लिए पास करना चाहिए या आप React.createElement उपयोग कर सकते हैं, तो

की तरह 0

Example