All around me (e.g. blog posts, code) I see code for React stateless functional components in which React
is imported even though it's never used.
import React from 'react';
function MyComponent() {
return <div>Howdy!</div>;
}
export default MyComponent;
I'm wondering why we need to import React when it's not actually used (in any explicit manner).
I'm also surprised that my linter doesn't complain about the un-used import.
Is there some reason to import React
into functional components that I'm not aware of?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…