preact-www icon indicating copy to clipboard operation
preact-www copied to clipboard

Differences to React: default state shape

Open gpoitch opened this issue 6 years ago • 6 comments

class App extends Component {
  render() {
    console.log(this.state) // react: null | preact: {}
  }
}

Can PR if you want to mention it.

gpoitch avatar Jan 20 '19 21:01 gpoitch

tbh I never realized that was the case in React. Maybe we shouldn't both initializing it in preact either?

developit avatar Feb 14 '19 21:02 developit

Yea was surprised by it. Here's the proof: React: https://codesandbox.io/s/qx8971z77w Preact: https://codesandbox.io/s/15jxo4x2q

gpoitch avatar Feb 14 '19 21:02 gpoitch

IIRC this is corrected in Preact X.

developit avatar Jul 08 '19 12:07 developit

Still {} in Preact X: https://codesandbox.io/s/heuristic-bohr-t586n

gpoitch avatar Jul 08 '19 13:07 gpoitch

We had null for a while in X but changed it back to an empty object for size reasons 👍

marvinhagemeister avatar Jul 08 '19 15:07 marvinhagemeister

good to know!

developit avatar Jul 09 '19 15:07 developit