-
-
Save OliverJAsh/65bf16f6b388a4c16e20551a8839bdaa 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 * as React from "react"; | |
import * as ReactDOM from "react-dom"; | |
import { Provider, connect, ConnectedProps } from "react-redux"; | |
import { store, increment } from "./store"; | |
const divEl = document.querySelector("div"); | |
const Counter: React.FC<ConnectedProps<typeof connectThis>> = ({ | |
count, | |
dispatch | |
}) => ( | |
<div> | |
<div>{count}</div> | |
<button | |
onClick={() => { | |
fetch("https://httpbin.org/get").then(() => { | |
dispatch(increment()); | |
dispatch(increment()); | |
}); | |
}} | |
> | |
Increment twice | |
</button> | |
</div> | |
); | |
const connectThis = connect(state => ({ count: state })); | |
const CounterEnhanced = connectThis(Counter); | |
ReactDOM.render( | |
<Provider store={store}> | |
<CounterEnhanced /> | |
</Provider>, | |
divEl | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment