Skip to main content
100%

Smiley Face Part IV (React Components & ES6)

✓ Published1🌍 Public
IIlgar Akalın
Last edited Sep 16, 2021
Created on Sep 16, 2021

This example shows a yellow smiley face built from SVG primitives, with yellow circular background, two black eyes, and a curved mouth. It demonstrates how to combine React components with D3’s arc generator for the mouth path. The code uses React and ReactDOM for rendering, D3’s `arc()` method for path data, and ES6 features like arrow functions, destructuring, and template literals. The face is centered on a 960×500 canvas, with eyes offset by fixed pixel values and the mouth drawn as an arc between specified angles.

AI-generated description

Part IV

  1. React Components
  2. React Props
  3. JSX transpilation
  4. ES6 (ECMAScript version 6) Background: Wiki.

ECMAScript is another name for javascript.

  1. ES5 Functions vs. ES6 Arrow Functions
  2. Variables: ES5 <span style="color:red">var</span> vs. ES6 <span style="color:red">let</span> and <span style="color:red">const</span>.
  • ES5 javascript syntax: (oldschool 2009-2015)
var square = function(x) { return x * x }
  • ES6 2015 new features:
    • ES6 modules
import * as moduleName from "..."; export const Foo
- arrow function with ( ( ) => { }) syntax
const square = x => x * x;
const square = x => (x * x);
  1. ES6 Destructuring
let { a, b } = object;
MIT Licensed

Similar vizzes