epiqueras epiqueras - 1 year ago 116
React JSX Question

Import React vs React, { Component }

Import React
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 Source

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.