Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous arrow function warning with Next.js #1161

Closed
k4rli opened this issue Dec 9, 2020 · 2 comments
Closed

Anonymous arrow function warning with Next.js #1161

k4rli opened this issue Dec 9, 2020 · 2 comments

Comments

@k4rli
Copy link

k4rli commented Dec 9, 2020

Describe the bug

Warning message appears about anonymous arrow function. yup 0.32.5

A codemod is available to fix the most common cases: https://nextjs.link/codemod-ndc
warn  - ./node_modules/yup/es/util/isSchema.js
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;

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

./node_modules/yup/es/util/isAbsent.js
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;

A codemod is available to fix the most common cases: https://nextjs.link/codemod-ndc
@jquense
Copy link
Owner

jquense commented Dec 9, 2020

This looks like a bug in Next, isSchema isn't a react component it shouldn't be checking it

@jquense jquense closed this as completed Dec 9, 2020
@tomdohnal
Copy link
Contributor

I've come across this warning too and would like to revisit the issue.

  1. I don't even if it's possible for libraries like Next.js to know is a function is or is not a React component.
  2. I believe that changing
export default (value: any): value is undefined | null => value == null;

to

const isAbsent = (value: any): value is undefined | null => value == null
export default isAbsent;

is not such a big deal. (Happy to send a PR)

Would you be willing to merge a PR with these changes? @jquense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants