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

I have this code in my pagesindex.js file:import React from 'react';import dynamic from &#

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;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744845457a4596807.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信