Last active
December 9, 2018 04:06
-
-
Save rocifier/e844e7957af227128169a5dae99a2c72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import TeacherIntroductions from './components/TeacherIntroductions'; | |
import './App.css'; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<TeacherIntroductions /> | |
</div> | |
); | |
} | |
} | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { Provider } from 'react-redux'; | |
import store from './redux/store'; | |
import './index.css'; | |
import App from './App'; | |
import * as serviceWorker from './serviceWorker'; | |
ReactDOM.render( | |
<Provider store={store}> | |
<App /> | |
</Provider>, | |
document.getElementById('root') | |
); | |
// If you want your app to work offline and load faster, you can change | |
// unregister() to register() below. Note this comes with some pitfalls. | |
// Learn more about service workers: http://bit.ly/CRA-PWA | |
serviceWorker.unregister(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initialState = { | |
allIds: [1, 3, 4], | |
byIds: { | |
1: { | |
name: 'Bob', | |
location: 'New Zealand', | |
videoUrl: 'https://www.youtube.com/embed/M7lc1UVf-VE' | |
}, | |
3: { | |
name: 'Jerry', | |
location: 'Norway', | |
videoUrl: 'https://www.youtube.com/embed/M7lc1UVf-VE' | |
}, | |
4: { | |
name: 'Xiao Rose', | |
location: 'USA', | |
videoUrl: 'https://www.youtube.com/embed/M7lc1UVf-VE' | |
}, | |
} | |
} | |
export default (state = initialState, action) => { | |
return state; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { connect } from "react-redux"; | |
//import TeacherIntroduction from './TeacherIntroduction'; | |
const TeacherIntroduction = ({key, teacher}) => ( | |
<li className="teacher-introduction">{teacher}</li> | |
) | |
const TeacherIntroductions = (teachers) => ( | |
<ul className="teacher-introductions"> | |
{Object.entries(teachers.byIds).forEach(([id, info]) => { | |
return <TeacherIntroduction key={id} teacher={info} /> | |
})} | |
</ul> | |
) | |
const mapStateToProps = state => { | |
return state.TeacherIntroductions | |
} | |
export default connect(mapStateToProps)(TeacherIntroductions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment