Skip to content

Instantly share code, notes, and snippets.

@leihuagh
Created April 20, 2018 18:47
Show Gist options
  • Select an option

  • Save leihuagh/adf453f874c5e0f69abeeb76d585d69b to your computer and use it in GitHub Desktop.

Select an option

Save leihuagh/adf453f874c5e0f69abeeb76d585d69b to your computer and use it in GitHub Desktop.
Material-ui app.js
import React, { Component, Fragment } from 'react'
import { Header, Footer } from './layouts'
import Exerciese from './exercises'
import { muscles, exercises } from './../store'
export default class App extends Component {
constructor(props) {
super(props)
this.state = {
exercises
}
}
getExercisesByMuscles() {
return Object.entries(
this.state.exercises.reduce((exercises, exercise) => {
const { muscles } = exercise
exercises[muscles] = exercises[muscles]
? [...exercises[muscles], exercise]
: [exercise]
return exercises
}, {})
)
}
render() {
const exercises = this.getExercisesByMuscles()
return (
<Fragment>
<Header />
<Exerciese exercises={exercises} />
<Footer muscles={muscles} />
</Fragment>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment