我尝试将 Material UI 导入到我的 React On Rails 项目中。
一切正常,只是只有ModuleRaisedButton
不能用,
每次我尝试导入RaisedButton
时,我都会收到如图所示的错误消息。
我的代码如下:
import ReactOnRails from 'react-on-rails';
import PropTypes from 'prop-types';
import React from 'react';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import RaisedButton from 'material-ui/RaisedButton';
const App = () => (
<MuiThemeProvider>
<RaisedButton label="hi"/>
</MuiThemeProvider>
)
ReactOnRails.register({
App,
});
更新
hello_world/index.html.erb:
<h1>Hello World</h1>
<%= react_component("App", props: @hello_world_props, prerender: false) %>
布局/hello_world.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>ReactOnRailsWithWebpacker</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'webpack-bundle' %>
</head>
<body>
<%= yield %>
</body>
</html>
我该如何解决?或者这只是 React On Rails Gem 中的错误?