Skip to content

Instantly share code, notes, and snippets.

View harshmaur's full-sized avatar
🎯
Focusing

Harsh Maur harshmaur

🎯
Focusing
View GitHub Profile
// this wrapper component was never a Route! Just another way
// the old version "recreated react rendering"
<Route component={Wrapper}>
<Route path="/foo" component={Foo}/>
<Route path="/bar" component={Bar}/>
<Route path="/baz" component={Baz}/>
</Route>
// whenever one of those paths matched, you'd get something like
// <Wrapper><Foo/></Wrapper>
@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (