P粉4208682942023-08-31 11:11:27
For arrow functions, since they are anonymous, you need to assign it to a variable and then export it. Based on your code, this example should work (but don't forget to fill in the logic in the tasks.map function)
import React from 'react'; import TaskList from './TaskList'; const Tasks = ({ tasks }) => { return tasks.map(task => ( ... )); } export default Tasks;
This is caused by the import/no-anonymous-default-export
rule, which prevents a module's default export from being unnamed.
Since this is just a lint warning and not a syntax error, your existing code will work if you disable the rule (but I recommend not to do this!).
This rule is useful because ensuring that default exports are named helps improve the searchability of the code base by encouraging reuse of the same identifier at declaration locations and import locations.