Last active
May 1, 2018 04:43
-
-
Save deminoth/5250713f4ea8a325d756cbd59707ba29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { createStore } from "redux"; | |
import { Provider, connect } from "react-redux"; | |
function theme(state, action) { | |
return { | |
theme: "dark" | |
}; | |
} | |
const store = createStore(theme); | |
class App extends React.Component { | |
render() { | |
return ( | |
<Provider store={store}> | |
<Toolbar /> | |
</Provider> | |
); | |
} | |
} | |
function Toolbar(props) { | |
return ( | |
<div> | |
<ThemedButton /> | |
</div> | |
); | |
} | |
const mapStateToProps = state => { | |
return { | |
theme: state.theme | |
}; | |
}; | |
const ThemedButton = connect(mapStateToProps)(props => ( | |
<button theme={props.theme} /> | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment