Load data from backend before rendering a React component – best practice

Where to put the data fetching code? componentWillMount() ? Not any more. It’s been deprecated. You have no choice but put it inside componentDidMount() , which is recomendded by React. However ther is a big issue. componentDidMount() is actually AFTER render(). It "works" because after componentDidMount() finishes its job and changes some state, render() will …

Load data from backend before rendering a React component – best practice Read More »

Date types for createdAt and updatedAt in MySQL

If you really want them work well, : 1. Make sure your mysql’s version is 5.6.5+ 2. The two columns exact data types must be createdAt timestamp not null DEFAULT CURRENT_TIMESTAMP, updatedAt timestamp null DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP

html5 localStorage pitfalls

It doesn’t disappear after window closed It doesn’t expire The old standard of it only allow string to be saved. New standard is not like so, but all mainstream browsers still use the old standard.

Why is there white space above the header?

I set no margin or padding at all, but there is white space above the header. <header style=”background-color:gray”> <h1>Test margin collapsing</h1> </header> There is no margin in the "header" or "h1". So why? First of all, the browser adds margin to "h1". Open your developer console, you can see things like "-webkit-margin-before: 0.67em;" So there …

Why is there white space above the header? Read More »