Open kravchenko2805 opened 11 months ago
https://codesandbox.io/p/sandbox/dynamic-preload-value-v5jhv4?file=%2Fpages%2Findex.tsx%3A1%2C1&embed=1
Documentation says that preload takes boolean:
const isPreload = boolean;
if I'm trying to add ternary to preload:
preload
const fontName = localFont({ src: '...', weight: '...', preload: isPreload, });
IDE is OK with it, but dev server falls on browser:
Current: preload option of localFont cannot take ternary expression
Expected behavior: preload option of localFont can take ternary expression
Relevant Packages: next: 13.5.5-canary.5 eslint-config-next: 13.4.1 react: 18.2.0 react-dom: 18.2.0 typescript: N/A Next.js Config: output: N/A
Font optimization (next/font)
No response
hey @kravchenko2805 I think localFont is evaluated at compile time and you are assigning it a boolean which is not known at compile time thats why you are getting that error.
localFont
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/dynamic-preload-value-v5jhv4?file=%2Fpages%2Findex.tsx%3A1%2C1&embed=1
To Reproduce
Documentation says that preload takes boolean:
const isPreload = boolean;
if I'm trying to add ternary to
preload
:IDE is OK with it, but dev server falls on browser:![image](https://github.com/vercel/next.js/assets/78727936/20f134da-51a3-4fbd-90f7-ce1fa4c99906)
Current vs. Expected behavior
Current:
preload
option of localFont cannot take ternary expressionExpected behavior:
preload
option of localFont can take ternary expressionVerify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
Font optimization (next/font)
Additional context
No response