...

/

Map, Reduce & Filter in React

Map, Reduce & Filter in React

In this lesson, we'll demonstrate how the map, reduce, and filter methods are used in JavaScript and applied in React.

What’s the best approach for​ teaching the JSX syntax for React newcomers? Usually, I start out with defining a variable in the render() method and using it as JavaScript in HTML in the return block.

import React from 'react';
require('./style.css');

import ReactDOM from 'react-dom';
import App from './app.js';

ReactDOM.render(
  <App />,
  document.getElementById('root')
);

You only have to use the curly braces to get your JavaScript in HTML. Going from rendering a string to a complex object isn’t any different.

import React from 'react';
require('./style.css');

import ReactDOM from 'react-dom';
import App from './app.js';

ReactDOM.render(
  <App />,
  document.getElementById('root')
);

Usually, the next question then is: How to render a list of items? That’s one of the best parts about explaining React in my opinion. There is no ...