Skip to content

Instantly share code, notes, and snippets.

@deminoth
Last active May 1, 2018 04:43
Show Gist options
  • Save deminoth/5250713f4ea8a325d756cbd59707ba29 to your computer and use it in GitHub Desktop.
Save deminoth/5250713f4ea8a325d756cbd59707ba29 to your computer and use it in GitHub Desktop.
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