tinyplex / tinybase

The reactive data store for local‑first apps.
https://tinybase.org
MIT License
3.23k stars 65 forks source link

StoreInspector requires ui-react/debug #104

Closed marbemac closed 4 weeks ago

marbemac commented 8 months ago

Describe the bug

Getting the There are no Stores or other objects to inspect. Make sure you placed the StoreInspector inside a Provider component. message in the StoreInspector.

Pretty sure it's a context mismatch issue. Adjusting my ui-react import to use the debug build (e.g. import * as UiReact from 'tinybase/debug/ui-react/with-schemas'; fixes the issue (but obviously don't want to ship with this).

Looking at the build output of ui-react-dom (lib/debug/ui-react-dom.js), it's importing what it needs from ui-react from ./ui-react (the debug version), so the react context isn't matching up if end user is using non debug ui-react.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Follow the documentation on setting up the StoreProvider (I'm using imports, not script tags w UMD build, in case that matters).
  2. See issue

Expected behavior

No response

Screenshots or Videos

No response

Platform

No response

Additional context

No response

jamesgpearce commented 8 months ago

Yes... I've hit this in the past too. You currently need both the ui-react and ui-react-dom libraries to be the debug version (on the assumption they will be compiled away for prod). I'm not 100% this can be mitigated, but I will have a go.

marbemac commented 8 months ago

What is the difference between the debug versions and the regular versions? When using something like Vite to bundle everything up for prod, is there any downside to using the debug versions vs the non debug?

If no downside, then maybe it's just a matter of updating the StoreInspector docs to point out one must use the debug version of ui-react - right now the example shows using the regular ui-react:

Screenshot 2023-10-29 at 4 41 44 PM
jamesgpearce commented 8 months ago

Apart from the presence of the inspector it's just that the debug version is not minified. If I can't fix it to be more intuitive, I will do a better job of documenting it, for sure.

jamesgpearce commented 4 weeks ago

Check out the new v5.0.0-beta.21 release: in it, the StoreInspector (now called Inspector) is in its own module that can run in either debug or non-debug mode.

Hoping we can close this out, but please check and re-open if not!

https://beta.tinybase.org/guides/releases/#the-tinybase-inspector