【问题标题】:Rails React Component Renders But Not Visible on PageRails React 组件呈现但在页面上不可见
【发布时间】:2017-05-14 08:52:53
【问题描述】:

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

请看我附上的图片。 javascript 好像没有编译好??

Body inspection part 2

index.html.erb 代码

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

Message.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

HTML body inspection

【问题讨论】:

    标签: ruby-on-rails reactjs heroku


    【解决方案1】:

    我在安装 react-rails 之前恢复到 git commit 并改用 shakacode react-on-rails gem 并让它工作

    【讨论】:

      猜你喜欢
      • 2021-03-20
      • 1970-01-01
      • 2019-07-06
      • 1970-01-01
      • 1970-01-01
      • 2013-06-20
      • 1970-01-01
      • 1970-01-01
      • 2021-06-09
      相关资源
      最近更新 更多