epiqueras epiqueras - 3 months ago 16
React JSX Question

Import React vs React, { Component }

Import React
vs
Import React, { Component }


Which one is better and why?

Or does it make no difference other than writing less code later on?

Does writing
{ Component }
mean it only imports the Component object?

Answer

Import React, { Component } lets you do class Menu extends Component instead of class Menu extends React.Component. It's less typing and duplication of the React namespace. Beyond that it's entirely personal preference.