React: loop inside JSX code

If you are using React JS and want to add a component multiple times, maybe inserting it into some JSX code, you could think of using a for loop inside the return statement of your JSX. But this approach doesn’t work in JSX, as you should compose the returned value from the render function of … Continue reading “React: loop inside JSX code”

How to turn off ESLint rule via config file or via javascript

ESLint is fully configurable, so you are able to turn off linting rules. There are two ways for disabling rules: you can tell ESLint to do this from a Javascript comment or from a configuration file. How to turn off an ESLint rule from the .eslintrc config file To disable specific rules from the .eslintrc … Continue reading “How to turn off ESLint rule via config file or via javascript”

Javascript module pattern with constructor with arguments

As Douglas Crockford wrote on Javascript: the good parts, a module is a function or object that presents an interface but hides its state and implementation. I used indeed the module pattern once I needed encapsulation, i.e. to have a class method that had a public interface but that hid implementation details. In addition to encapsulation I … Continue reading “Javascript module pattern with constructor with arguments”

Javascript module pattern con costruttore con argomenti

Come scritto su Javascript: the good parts, un modulo è una funzione o un oggetto che presenta una interfaccia ma nasconde il suo stato e la sua implementazione. Ho infatti utilizzato il pattern module quando ho avuto la necessità di incapsulamento, cioè di avere un metodo di una classe che avesse una interfaccia pubblica ma … Continue reading “Javascript module pattern con costruttore con argomenti”

How to use React from the browser

React, as you probably know having reached this page, is a visualization framework created by Facebook. This small guide explains how to use react from the browser without any additional tool. Professional development with React nowadays includes the usage of npm (node package manager) to install packages like React and ReactDOM, and that of module bundlers … Continue reading “How to use React from the browser”

Create a production build using React JS

You probably saw some warnings that say you’re using React in development mode, and want to know how to create a production build using React. Why you get a warning of being in React development mode Normally you import React JS in your javascript ECMA 6 code with the following statements in a .js file … Continue reading “Create a production build using React JS”

How to downgrade from React JS 16 to 15

If you, as me, upgraded React 15 to 16, and then noticed a bug in you app, you’d like to downgrade, at least temporarily, to React 15. To do this, you need to issue the following command:

This will bring React to version 15.6.2 again. After fixing the bug, you can run the following … Continue reading “How to downgrade from React JS 16 to 15”