Posts

Showing posts with the label import

Print static text in React by webpack using Function component

Image
Install Webpack and configure it first See installation and configuration in my other blog Now Create a file into a public folder or anywhere into Root directory inside your project folder Create to directory into root directory         mkdir public           mkdir src Create two new into public folder index.html index.js Create a new file into src folder main.js Copy and paste code into index.html <!DOCTYPE html> <html> <head> <title>React - demo</title> </head> <body> <div id="root"></div> <script src="index.js"></script> </body> </html> Now into main.js import React from 'react'; import ReactDOM from 'react-dom'; function Welcome() { return (<div> Hello </div>) } const root = document.getElementById('root');  ReactDOM.render(<Welcome />, root); Project Structure will be like this

Print static text in React by webpack using class component

Image
Install Webpack and configure it first See installation and configuration in my other blog Now Create a file into a public folder or anywhere into Root directory inside your project folder Create to directory into root directory         mkdir public           mkdir src Create two new into public folder index.html index.js Create a new file into src folder main.js Copy and paste code into index.html <!DOCTYPE html> <html> <head> <title>React - demo</title> </head> <body> <div id="root"></div> <script src="index.js"></script> </body> </html> Now into main.js import React from 'react'; import ReactDOM from 'react-dom'; class Welcome extends React.Component{ render(){ return( <div> Hello  </div> ); } } const root = document.getElementById('root');  ReactDOM.render(<Welcome />, root);