Skip to content

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

2 participants