Tuesday, May 23, 2017

Import and require difference in react

Require:
This allows us to have dynamically load module which isnt predefined or we can also conditionally load  a module when we reuire it.
Ex: var Navitem =require ("./components/NavItem");
Imports:
We can use ES6 import to selectively load the pieces which we need and by doing this we can save memory.
import Navitem from("./components/NavItem);


require is in ES 5 and in ES 6 we make use of import

No comments:

Post a Comment

Call a function in child component from parent component in React

Consider the following parent component class Parent extends React.Component { constructor(props) { super(props);         thi...