Skip to content

Instantly share code, notes, and snippets.

@rocifier
Last active December 9, 2018 04:06
Show Gist options
  • Save rocifier/e844e7957af227128169a5dae99a2c72 to your computer and use it in GitHub Desktop.
Save rocifier/e844e7957af227128169a5dae99a2c72 to your computer and use it in GitHub Desktop.
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;
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();
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;
}
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