Skip to content

Commit

Permalink
Installed Material UI and amended example MUI and react component
Browse files Browse the repository at this point in the history
  • Loading branch information
swissbusybee committed Nov 14, 2020
1 parent 55244d3 commit 8bd7263
Show file tree
Hide file tree
Showing 6 changed files with 11,053 additions and 26 deletions.
13 changes: 8 additions & 5 deletions app/javascript/components/HelloWorld.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import React from "react"
import PropTypes from "prop-types"
import React from "react";
import PropTypes from "prop-types";
import FaceIcon from "@material-ui/icons/Face";

class HelloWorld extends React.Component {
render () {
render() {
return (
<React.Fragment>
Greeting: {this.props.greeting}
<FaceIcon />
</React.Fragment>
);
}
}

HelloWorld.propTypes = {
greeting: PropTypes.string
greeting: PropTypes.string,
};
export default HelloWorld
export default HelloWorld;
30 changes: 12 additions & 18 deletions app/javascript/packs/hello_react.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
// Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
// like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
// of the page.
import React from "react";
import ReactDOM from "react-dom";
import PropTypes from "prop-types";

import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'

const Hello = props => (
<div>Hello {props.name}!</div>
)
const Hello = (props) => <div>Hello {props.name}!</div>;

Hello.defaultProps = {
name: 'David'
}
name: "David",
};

Hello.propTypes = {
name: PropTypes.string
}
name: PropTypes.string,
};

document.addEventListener('DOMContentLoaded', () => {
document.addEventListener("DOMContentLoaded", () => {
ReactDOM.render(
<Hello name="React" />,
document.body.appendChild(document.createElement('div')),
)
})
document.body.appendChild(document.createElement("div"))
);
});
2 changes: 1 addition & 1 deletion app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= link_to "/", class: "navbar-brand" do %>
<%= image_tag "logo_smcompass1.png", class: "avatar"%>
<%# This is for demonstration purposes only %>
<%= react_component("HelloWorld", { greeting: "Hello from react-rails." }) %>
<%= react_component("HelloWorld", { greeting: "Hello from react-rails!" }) %>
<% end %>
<% if current_user.nil? %>
<%= "" %>
Expand Down
Loading

0 comments on commit 8bd7263

Please sign in to comment.