0

I am new to React native, while going through the docs I found that in React Native the components are written without implementing the constructor() function and the states are declared directly in the class. I wonder why that is, as opposed to states being declared inside the constructor like in React.

example from React Native doc:

import React, { Component } from "react";
import { Button, Text, View } from "react-native";

class Cat extends Component {
  state = { isHungry: true };

  render() {
    return (
      <View>
        ...
      </View>
    );
  }
}
hedgehog
  • 3
  • 2

1 Answers1

0

As it turns out, both ways are valid if you are using Babel, and this article explains it well!

hedgehog
  • 3
  • 2