lingo.dev icon indicating copy to clipboard operation
lingo.dev copied to clipboard

Add Suspense fallback to LingoProviderWrapper

Open verma-divyanshu-git opened this issue 1 month ago • 5 comments

  • wrapped the client provider in Suspense so we don’t flash blank screens while dictionaries load

  • added a default fallback component plus a fallback prop for teams that want custom UI

  • updated tests to cover the fallback path, error boundaries, and custom render cases

  • ran pnpm --filter @lingo.dev/_react test and verified the Vite demo (dictionary loads immediately so fallback flashes only for a beat on localhost)

Screenshot 2025-11-05 at 1 18 17 AM

verma-divyanshu-git avatar Nov 04 '25 19:11 verma-divyanshu-git

Hey @verma-divyanshu-git please link the issue this will solve and only raise a PR after being assigned to an issue.

sumitsaurabh927 avatar Nov 04 '25 21:11 sumitsaurabh927

please update base, it is out of date

sumitsaurabh927 avatar Nov 04 '25 21:11 sumitsaurabh927

@verma-divyanshu-git you need to update the title:

Error: No release type found in pull request title " Add Suspense fallback to LingoProviderWrapper". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

sumitsaurabh927 avatar Nov 04 '25 21:11 sumitsaurabh927

And also make sure you're added changeset

sumitsaurabh927 avatar Nov 04 '25 21:11 sumitsaurabh927

I'd like to review this at some point, if that's okay. If I don't review it within 24 hours and you need to merge it, just merge it.

The-Best-Codes avatar Nov 04 '25 23:11 The-Best-Codes

hey, @sumitsaurabh927, @The-Best-Codes , I have made all the changes, sorry for the trouble

verma-divyanshu-git avatar Nov 05 '25 05:11 verma-divyanshu-git

One thing I notice: I can't remove the fallback. Setting it to null doesn't work, it continues to use the default one. IMO, the fallback should be null by default, and you can opt-in to using the default fallback or a custom component.

The-Best-Codes avatar Nov 06 '25 20:11 The-Best-Codes

@The-Best-Codes , Sorry, my bad. The ?? operator treats null as a fallback trigger, so passing fallback={null} still shows the default.

Should I change it so the fallback defaults to null (no UI) and users opt-in with <LingoProviderFallback /> if they want the loading message?

verma-divyanshu-git avatar Nov 06 '25 20:11 verma-divyanshu-git

@verma-divyanshu-git Yes, I think that would be best.

The-Best-Codes avatar Nov 06 '25 20:11 The-Best-Codes

@The-Best-Codes , Done! Fallback now defaults to null (no UI). Users opt-in with fallback={<LingoProviderFallback />} if they want the loading message. Just pushed the fix.

verma-divyanshu-git avatar Nov 06 '25 20:11 verma-divyanshu-git