Closed alexanderkalachev closed 1 year ago
It is, in the section about loading languages there is an async example. The function here actually has the client as the first param so it could be:
languages: async (client) => {
const response = await client.fetch(`*[_type == "language"]{ id, title }`)
return response
}
I tried this:
plugins: [
deskTool(),
visionTool(),
internationalizedArray({
languages: async (client) => {
const response = await client.fetch(`*[_type == "language"]{ id, title }`);
return response;
},
fieldTypes: ['string']
})
],
and still having the same error:
Unhandled Runtime Error
TypeError: k.filter is not a function
Call Stack
U
node_modules/sanity-plugin-internationalized-array/lib/index.esm.js (1:3047)
renderWithHooks
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (18082:0)
mountIndeterminateComponent
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (23209:0)
beginWork
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (24786:0)
HTMLUnknownElement.callCallback
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (4246:0)
Object.invokeGuardedCallbackDev
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (4295:0)
invokeGuardedCallback
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (4359:0)
beginWork$1
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (32207:0)
performUnitOfWork
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (31082:0)
workLoopSync
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (30891:0)
renderRootSync
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (30856:0)
performSyncWorkOnRoot
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (30368:0)
flushSyncCallbacks
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (14254:0)
eval
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (29896:0)
I have updated the readme example in #11, re-open this if you still cannot get this feature to work.
If yes, what would be the function? I'm trying something like:
But it return a promise as a language list instead of an array.