Comments (8)
I am facing a similar issue to this, but the error message I get is:
✖ Could not find binding for import "useLocale" in next-intl in "../src/app/[locale]/trails/page.tsx"
This is the relevant code from my
../src/app/[locale]/trails/page.tsx
file:import { groq } from 'next-sanity'; import { useLocale } from 'next-intl'; export default async function Trails() { const locale = useLocale(); const TRAILS_QUERY = groq`*[_type == "trail" && language == "${locale}"]{ _id, name }`;I need the
locale
parameter to be dynamic based on the user's locale, so this issue is blocking me from using TypeGen in my project.
Hey, in your case that is a different issue, you should be using prepared queries, so you would not be concatenating strings at all, you would send the locale param as a second argument
example
sanityClient.fetch(
`*[_type == "orders" && orderId.current == $orderId][0]{...}`,
{orderId: query.orderId}
)
from sanity.
Thanks a lot! I have a fix lined up here #6540
from sanity.
I am facing a similar issue to this, but the error message I get is:
✖ Could not find binding for import "useLocale" in next-intl in "../src/app/[locale]/trails/page.tsx"
This is the relevant code from my ../src/app/[locale]/trails/page.tsx
file:
import { groq } from 'next-sanity';
import { useLocale } from 'next-intl';
export default async function Trails() {
const locale = useLocale();
const TRAILS_QUERY = groq`*[_type == "trail" && language == "${locale}"]{
_id,
name
}`;
I need the locale
parameter to be dynamic based on the user's locale, so this issue is blocking me from using TypeGen in my project.
from sanity.
I am facing a similar issue to this, but the error message I get is:
✖ Could not find binding for import "useLocale" in next-intl in "../src/app/[locale]/trails/page.tsx"
This is the relevant code from my../src/app/[locale]/trails/page.tsx
file:import { groq } from 'next-sanity'; import { useLocale } from 'next-intl'; export default async function Trails() { const locale = useLocale(); const TRAILS_QUERY = groq`*[_type == "trail" && language == "${locale}"]{ _id, name }`;I need the
locale
parameter to be dynamic based on the user's locale, so this issue is blocking me from using TypeGen in my project.Hey, in your case that is a different issue, you should be using prepared queries, so you would not be concatenating strings at all, you would send the locale param as a second argument
example
sanityClient.fetch( `*[_type == "orders" && orderId.current == $orderId][0]{...}`, {orderId: query.orderId} )
Thanks, and it's working for me now. Concatenation was working for me to get the data so I assumed that the issue was with sanity typegen
. Now only the original issue which you reported remains.
from sanity.
#6457 Does not seems to fix all cases still getting Cannot find module
if I use relative imports. Seems to happen when I have a fragments composed of other fragments.
from sanity.
@georgeosutton Do you have a reproduction either in a repo or a gist somewhere?
from sanity.
I've added a folder with relevant fragments / query.
I get the following when I run pnpm run typegen
Cannot find module 'C:\Users\George\Documents\GitHub\typegen-reproduction\fragments\image'
Require stack:
- C:\Users\George\Documents\GitHub\typegen-reproduction\node_modules\.pnpm\@[email protected]\node_modules\@sanity\codegen\lib\index.js
- C:\Users\George\Documents\GitHub\typegen-reproduction\node_modules\.pnpm\@[email protected]\node_modules\@sanity\cli\lib\workers\typegenGenerate.js in "./src/sanity/lib/queries.ts"
from sanity.
fix for this was released yesterday, v3.41.0
from sanity.
Related Issues (20)
- Sanity npm package throws type error on build HOT 3
- Ability to order documents using an array value
- Hide schedule action in some documents
- Unable to upload images to block content type field on Safari
- Introduce Selective CLI Logging Suppression
- How can I restrict access to resources only through my domain? HOT 2
- TypeGen not generating union type for string array with list option
- can't use `npx @sanity/cli init --template shopify` with the next.js embedded studio option
- On >3.41.0 dragging blocks in PTE gives "Can't upload this file here" error HOT 1
- TypeGen generates Array<never> for query using "in" HOT 1
- TypeGen generates Array<never> for query using chained parent operator
- Hang introduced by #5269, (a0f93cb) (fix included) HOT 3
- Typegen: Can't generate types with conditional values in slice and ordering operations even when the it doesn't effect the type. HOT 1
- All Studio UI menus broken/empty in Dev HOT 1
- Both new and legacy search don't work with documents with a custom title field
- Desk tool crash: editOpsOf does not expect a draft id HOT 1
- throw new Error("'block' type is not defined in this schema (required).");
- Cannot Paste Into Block Content HOT 1
- Provide HTML as a content type for rich text
- The structure tool crashed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanity.