Posts

Showing posts with the label react-dom

Features of Sql * Plus

Features of Sql * Plus At a time only one query is allowed to execute Sql queries are not case sensitive Each query is terminated with ; ( semi colon ) SQL commands are ANSI standard ( American National standard institute )

Export Import component in react

Image
 Export Import component in react 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 two new file into src folder main.js  item.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 item.js import React from 'react'; class Item extends React.Component{ render(){ return( <div> Hello Item </div> ); } } export default Item; // you must have to make component exportable Now into main.js import React from 'react&#

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);

The 'mode' option has not been set, webpack will fallback to 'production' for this value

WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/ module.exports = {   mode: "development", // Add mode here to solve this warning    entry: './src/main.js', // Bundle all assets from this location together    output: {        filename: 'index.js', // Output to this file        path: path.resolve( __dirname, 'public' ), // In this location    }

Install webpack in react Application || install babel

Run this commands form terminal or cmd npm init npm i webpack --save-dev npm i webpack-cli --save-dev  npm install -D babel-loader @babel/core @babel/preset-env webpack  npm i @babel/preset-react --save-dev npm i babel-core --save-dev npm i babel-preset-env --save-dev npm i babel-preset-es2015 babel-preset-react babel-preset-stage-0 --save-dev npm i react react-dom --save-dev npm install webpack-dev-server -g   // In window and mac os this command will not work then use this npm i webpack-dev-server --save-dev Create a new file named Webpack.config.js into root directory copy and paste this code into webpack.config.js file var path = require('path'); module.exports = {    entry: './src/main.js', // Bundle all assets from this location together    output: {        filename: 'index.js', // Output to this file        path: path.resolve( __dirname, 'public' ), // In this location    },    module: {        rules: [        

set mode on webpack.config.js || webpack file configuration

Give mode in webpack.config.js            mode: "development || production"  //whatever you want to give Use it before Entry module.exports = {   mode: "development",    entry: './src/main.js', // Bundle all assets from this location together    output: {        filename: 'index.js', // Output to this file        path: path.resolve( __dirname, 'public' ), // In this location    }, 

React Application by Webapck || webpack install

Image
Create a directory into your local         for windows            mkdir react-demo         for linux                       mkdir react-demo Go to directory             cd react-demo Type npm init            for installing node and creating package.json file npm i webpack --save-dev           create dependency by webpack npm i webpack-cli --save-dev           This cmd is used to create dependency for webpack-cli in package.json file.           Like -             "devDependencies": {            "webpack": "^4.16.2",            "webpack-cli": "^3.1.0"             } npm install -D babel-loader @babel/core @babel/preset-env webpack "devDependencies": {    "babel-core": "^6.26.3",    "babel-loader": "^7.1.5",    "babel-preset-env": "^1.7.0",    "webpack": "^4.16.2",    "webpack-cli":