最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Anonymous arrow functions cause Fast Refresh to not preserve local component state - Stack Overflow

programmeradmin5浏览0评论

I have this code in my pages/index.js file:

import React from 'react';
import dynamic from 'next/dynamic';

const TVChartContainer = dynamic(
    () =>
        import('../ponents/TVChartContainer').then(mod => mod.TVChartContainer),
    { ssr: false },
);

export default () => <TVChartContainer />;

And this gives me an error.

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

Before export default () => ;

After const Named = () => ; export default Named;

A codemod is available to fix the most mon cases: /codemod-ndc

And then I tried to export the ponent this way.

export default  TVChartContainer;

This also seems not fixing the issue. How do I fix this issue?

I have this code in my pages/index.js file:

import React from 'react';
import dynamic from 'next/dynamic';

const TVChartContainer = dynamic(
    () =>
        import('../ponents/TVChartContainer').then(mod => mod.TVChartContainer),
    { ssr: false },
);

export default () => <TVChartContainer />;

And this gives me an error.

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

Before export default () => ;

After const Named = () => ; export default Named;

A codemod is available to fix the most mon cases: https://nextjs.link/codemod-ndc

And then I tried to export the ponent this way.

export default  TVChartContainer;

This also seems not fixing the issue. How do I fix this issue?

Share Improve this question edited Nov 6, 2021 at 11:24 juliomalves 50.6k23 gold badges178 silver badges169 bronze badges asked Nov 1, 2021 at 6:29 margherita pizzamargherita pizza 7,22729 gold badges103 silver badges178 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

As the error message suggests, you need to add a name to the function ponent you're exporting.

const IndexPage = () => <TVChartContainer />

export default IndexPage;
发布评论

评论列表(0)

  1. 暂无评论