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

KCL-11649 - Centralize smart link instance to context. provide smart … #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hejtmii
Copy link

@hejtmii hejtmii commented Oct 10, 2023

Motivation

When working on the sample site, I faced a problem of having multiple places with useSmartLink and not being sure if I could spin up more instances of SmartLink SDK.

I sometimes even got error saying something about SmartLink SDK being destroyed already. Unfortunately cannot reproduce reliably.

I reorganized SmartLink initialization code the following way:

  • Moved creation of the SmartLink SDK as a singleton to the top of the application, into SmartLinkProvider and exposed the SmartLink SDK instance via context
  • Created two handy hooks to access it
    • useSmartLink - Gives access to the SmartLink SDK singleton
    • useSmartLinkRefresh - Attaches the refresh callback to the SmartLink SDK, greatly reducing the boilerplate to handle page refresh (used on the Home page)

Checklist

  • [+] Code follows coding conventions held in this repo
  • [-] Automated tests have been added
  • [+] Tests are passing
  • [-] Docs have been updated (if applicable)
  • [+] Temporary settings (e.g. variables used during development and testing) have been reverted to defaults

How to test

When previewing in Web spotlight, the SmartLink actions should work (edit element / auto-refresh)

@hejtmii hejtmii requested a review from a team as a code owner October 10, 2023 16:43
@vercel
Copy link

vercel bot commented Oct 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ficto-healthtech ❌ Failed (Inspect) Oct 10, 2023 4:45pm
ficto-healthtech-qa ❌ Failed (Inspect) Oct 10, 2023 4:45pm
ficto-imaging ❌ Failed (Inspect) Oct 10, 2023 4:45pm
ficto-imaging-qa ❌ Failed (Inspect) Oct 10, 2023 4:45pm
ficto-surgical ❌ Failed (Inspect) Oct 10, 2023 4:45pm
ficto-surgical-qa ❌ Failed (Inspect) Oct 10, 2023 4:45pm

@netlify
Copy link

netlify bot commented Oct 10, 2023

Deploy Preview for new-sample-app failed.

Name Link
🔨 Latest commit e26fe18
🔍 Latest deploy log https://app.netlify.com/sites/new-sample-app/deploys/65257f429f92ab00085453c9

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.

1 participant