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 badges1 Answer
Reset to default 3As the error message suggests, you need to add a name to the function ponent you're exporting.
const IndexPage = () => <TVChartContainer />
export default IndexPage;