简体   繁体   English

在Codepen.io上使用React.js,为什么自定义标记不呈现?

[英]Using React.js on Codepen.io, Why is the custom tag not rendering?

A very beginner and dumb question maybe but still, everyone learns at first.. 也许但仍然是一个非常初学者和愚蠢的问题,每个人都首先学习。

HTML 的HTML

<div class="container" id="container">

CSS(SCSS) CSS(SCSS)

$back:#1D1F20;
$font:'Open Sans',sans serif;
body{
  background-color:$back;
  padding:20px;
  h1{
    font-family:$font;
    color:white;
  }
  DisplayBox{
    font-family:$font;
    color:white;
  }
}

JS (Babel) JS(通天塔)

var DisplayBox=React.createClass({
  render:function(){
        return (
          <h1>Marked</h1>
        );
    }
});

React.render(<DisplayBox />,document.getElementById("container"));

My aim is to render the custom tag DisplayBox inside the #container but it is not rendering in codepen.io JS config in Codepen CSS config 我的目标是使#container的内部的自定义标签显示框,但它不是在codepen.io渲染JS配置在Codepen CSS配置

Thank you for your help in advance :-) 提前谢谢你的帮助 :-)

Instead of 代替

React.render(<DisplayBox />,document.getElementById("container"));

Use 采用

ReactDOM.render(<DisplayBox />,document.getElementById("container"));

Check the working example 检查工作示例

Check the difference between React and ReactDOM 检查ReactReactDOM之间区别

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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