Closed fdfontes closed 11 months ago
OK, this looks like it could be a bug! But I just want to check you are only seeing this in React Native?
The metro bundler does not always resolve modules as TinyBase needs (due to exports
support in package.json), and my guess is that that might be part of the problem.
There's a PR waiting for you with the fixes :)
https://github.com/fdfontes/tinybase-rn-broken-queries-repro/pull/1
The TLDR is that you were trying to run queries on your typed Store API, but you need to run them against the underlying Store:
-const queries = createQueries(store);
+const queries = createQueries(store.getStore());
But the PR also includes some nice memoization and data access hooks to get you going.
Describe the bug
I used
tinybase getStoreApi <schemaFile> <storeName> <outputDir>
which allowed me to set & access data. However, I've been unable to use queries. I get the following error:TypeError: s is not a function (it is undefined)
(sometimesl is not a function
)I have tried both
createQueries
anduseCreateQueries
. I noticed thatcreateQueries
complains that store is not an instance ofStore
even though I used the command line above.Your Example Website or App
https://github.com/fdfontes/tinybase-rn-broken-queries-repro
Steps to Reproduce the Bug or Issue
tinybase getStoreApi <schemaFile> <storeName> <outputDir>
schema in this case isdbSchema.json
testStore-ui-react.d.ts
,testStore-ui-react.tsx
,testStore.d.ts
,testStore.ts
createQueries
inApp.js
Expected behavior
I expected to be able to set up queries.
Screenshots or Videos
Platform
Additional context
I tried to include
createQueries
anduseCreateQueries
in my UI files. The documentation isn't super clear on how queries work when using the auto generated UI. Perhaps I'm not understanding some element of the implementation.