I tried to import Material UI into my React On Rails Project.
Everything is okay, but just only Module RaisedButton
can't use,
Every time I try to import RaisedButton
, I will get the error message like the picture.
My code is below:
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) %>
layouts/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>
How can I fix it ? Or It's just the bug in React On Rails Gem?
I think I find the problem, I see the
node_module/material-ui/RaisedButton/RaisedButton.js
fileIn this code, there is the Obj key
ref
, I delete theref
, and the error would not appears.