Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created January 27, 2020 14:48
Show Gist options
  • Save OliverJAsh/65bf16f6b388a4c16e20551a8839bdaa to your computer and use it in GitHub Desktop.
Save OliverJAsh/65bf16f6b388a4c16e20551a8839bdaa to your computer and use it in GitHub Desktop.
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