Skip to content

Instantly share code, notes, and snippets.

@avin-kavish
Created March 30, 2020 10:58
Show Gist options
  • Save avin-kavish/1abeb5e0c89f4c38149006b6ffafdaab to your computer and use it in GitHub Desktop.
Save avin-kavish/1abeb5e0c89f4c38149006b6ffafdaab to your computer and use it in GitHub Desktop.
Overmind Basic Application
import React from "react"
import { createOvermind } from "overmind"
import { createHook, Provider } from "overmind-react"
const app = createOvermind({
state: {
counter: 0
},
actions: {
increment({ state }) {
state.counter++
}
}
})
const useApp = createHook()
function App() {
const { state, actions } = useApp()
return (
<>
<p>{state.counter}</p>
<button onClick={() => actions.increment()}>Increment</button>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment