Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

332
Visualizações
Next.js - Anonymous arrow functions cause Fast Refresh to not preserve local component state (warning)

I'm currently experiencing this warning pointing at an unnamed object in a config file, and naming it doesn't resolve the warning. Below is the detailed warning and examples.

Warning:

Anonymous arrow functions cause Fast Refresh to not preserve local component state.
Please add a name to your function, for example:

Before
export default () => <div />;

After
const Named = () => <div />;
export default Named;

Before:

export const = {
  apiUrl: process.env.NEXT_PUBLIC_API_URL as string,
  commitRef: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF as string,
  ldSdkKey: process.env.NEXT_PUBLIC_LD_SDK_KEY as string,
  imgixBaseUrl: process.env.NEXT_PUBLIC_IMGIX_BASE_URL as string,
  imgixApiKey: process.env.NEXT_PUBLIC_IMGIX_API_KEY as string,
  imgixResourceID: process.env.NEXT_PUBLIC_IMGIX_RESOURCE_ID as string,
};

Attempted Resolution ./src/config.ts:

const AppConfig = {
  apiUrl: process.env.NEXT_PUBLIC_API_URL as string,
  commitRef: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF as string,
  ldSdkKey: process.env.NEXT_PUBLIC_LD_SDK_KEY as string,
  imgixBaseUrl: process.env.NEXT_PUBLIC_IMGIX_BASE_URL as string,
  imgixApiKey: process.env.NEXT_PUBLIC_IMGIX_API_KEY as string,
  imgixResourceID: process.env.NEXT_PUBLIC_IMGIX_RESOURCE_ID as string,
};

export default AppConfig;

Hopefully someone else has experienced this and found a resolution.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Turns out the issue was that our older version of Next.js didn't point towards the correct cause of the warning, but still served the warning. Updating next guided me towards the problem code and I was able to resolve it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda