Rails React 组件呈现,但在页面上不可见



我刚刚将 react-rails gem 添加到我的项目中,并尝试将 react 组件添加到我的 index.html.erb 文件中。我使用 react 组件生成器制作了一个简单的消息/文本元素,但在我部署到 Heroku 后它没有显示在我的视图中,但在我检查页面时它似乎呈现了。我不知道为什么这不起作用。

请看我附上的图片。看起来javascript没有被编译??

车身检查第2部分

index.html.erb code

    <h2>Dashboard</h2>
    <%= react_component('Message', text: 'hello') %>
    <h3>Products TEST REACT </h3>

消息.jsx 代码

var React = require("react")
class Message extends React.Component {
  render () {
    return (
      <div>
        <div>Text: {this.props.text}</div>
      </div>
    );
  }
}
Message.propTypes = {
  text: React.PropTypes.string
};
module.exports = Message

网页机身检查

我在安装 react-rails

之前恢复到 git 提交,并使用 shakacode react-on-rails gem 代替并让它工作

最新更新