the es6 syntax for creating React component is export default class ExampleComponent extends React.Component
.However it still work when export default class ExampleComponent
without extends React.Component
on condition that import React from 'react'
; why this happen
It's easy to be in this situation and miss what's happening, but the difference is really huge: without extending React.Component, you're just creating a JS class. Furthermore:
React.createClass()
or as an ES6 class), it'll still "work", state
for everythingHope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With