Posts

Showing posts with the label reactjs

ReactJS-Function

< React Course Notes >< ReactJS function >  Functions: const square = function(x) {   return x * x; }; console.log(square(3)); // → 9 Function`s Parameters A function can have multiple parameters  const roundTo = function(n, step) {   let remainder = n % step;   return n - remainder + (remainder < step / 2 ? 0 : step); }; console.log(roundTo(23, 10)); // → 20 or no parameters at all const makeNoise = function() {   console.log("Pling!"); }; makeNoise(); // → Pling! Nested functions const hummus = function(factor) {   const ingredient = function(amount, unit, name) {     let ingredientAmount = amount * factor;     if (ingredientAmount > 1) {       unit += "s";     }     console.log(`${ingredientAmount} ${unit} ${name}`);   };   ingredient(1, "can", "chickpeas");   ingredient(0.25, "cup", "tahini");   ingredient(0.25, "cup", "lemon juice");   ingredient(1, "...

React-course notes

< React Course Notes >< ReactJS function > I) installation: https://www.freecodecamp.org/news/react-for-beginners-handbook/ run msdos in C;// run the command: - This creates the working folder npm create vite@5.1.0 my-alorya-app -- --template react II) to start vite.js run in msdos: cd my-alorya-app change folder with cd my-app - in msdos This installs the app in the folder: npm install Run Vite.js:  npm run dev With vite all is ready! -  Watch out :  There should be no errors in the installation (red text).  If there are any, you should correct them. creating project (without vite.js) I recommend you just use vite.js and not the following, I found them too comples, and I had many errors to correct. Run the code -  Run them if you do not use vite.js - if you use vite.js you don`t need them npm init -y install react libraries npm install react@^17.0.0 react-dom@^17.0.0 --save install babel npm install @babel/preset-env @babel/preset-react @babel/core ...