Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify hook state #108

Merged
merged 1 commit into from
Aug 16, 2024
Merged

Simplify hook state #108

merged 1 commit into from
Aug 16, 2024

Conversation

timowestnosto
Copy link
Contributor

No description provided.

import { isNostoLoaded } from "../components/helpers"
import type { NostoClient } from "../types"
import type { NostoProviderProps } from "../components/NostoProvider"

type NostoScriptProps = Pick<NostoProviderProps, "account" | "host" | "shopifyMarkets" | "loadScript">

export function useLoadClientScript(props: NostoScriptProps) {
const { host, account, shopifyMarkets, loadScript = true } = props
const [clientScriptLoadedState, setClientScriptLoadedState] = useState(false)
const clientScriptLoaded = useMemo(() => clientScriptLoadedState, [clientScriptLoadedState])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't figure out the purpose of this wrapping
useMemo wrapping didn't seem to have any impact here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clientScriptLoadedState is already memoized by useState internally, so it's not needed here, yes.

@timowestnosto timowestnosto merged commit cbd2424 into master Aug 16, 2024
1 check passed
@timowestnosto timowestnosto deleted the simplify-hook-state branch August 16, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants