-
-
Save koenbok/09785fd0aa6c7449561bc5927ef7aaeb 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 type { ComponentType } from "react" | |
import { createStore } from "https://framer.com/m/framer/store.js@^0.3.0" | |
const useStore = createStore({ count: 0 }) | |
export const withCount = (Component): ComponentType => { | |
return (props) => { | |
const [store, setStore] = useStore() | |
return <Component {...props} text={`${store.count}`} /> | |
} | |
} | |
export const withIncrement = (Component): ComponentType => { | |
return (props) => { | |
const [store, setStore] = useStore() | |
const onTap = () => setStore({ count: store.count + 1 }) | |
return <Component {...props} onTap={onTap} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this code worked in preview, but not when publishing the site.
Updating store.js to 1.0.0 fixed that:
import { createStore } from "https://framer.com/m/framer/store.js@^1.0.0"
Thanks to Sakibul Islam for the solution (https://www.framer.community/c/developers/store-not-working-on-published-site).