Destructuring assignment

const name = 'cute';
const surname = 'luna';

var sayHello = function({ name, surname }) {
  var cute = 'fuck you'; 
  var fuck = 'fuck your dick';
  console.log(`Hello ${name} ${surname}! How are you?`);
  console.log({cute});
  console.log({cute:fuck});
};

sayHello({ name: 'John', surname: 'Smith' });
sayHello({ name, surname });

可以把上面直接貼在console,或是貼到babel玩玩

React Life Cycle

constructors

Do
  • create any fields (variables starting with this.)
  • initialize state based on props received
  • set initial state
  • if not using class properties syntax — prepare all class fields and bind functions that will be passed as callbacks
Don’t
  • cause any side effects (AJAX calls etc.)