我嘗試將Material UI導入到React On Rails項目中。在React On Rails中使用Material UI
一切都是好的,但僅僅只有模塊RaisedButton
不能使用,
每次我嘗試導入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,
});
UPDATE
程序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中的錯誤?
你能顯示你的佈局文件嗎? – Panther
@Panther你主要'DOM'? –
您的「rails」佈局文件。 – Panther