9import { convertData } from '../../utilities/convertData';
10
11export class Watch extends Component {
12 state = {13 data: null,14 }15
16 componentDidMount() {
17 const yourId = this.props.match.params.id;
6import { url } from '../../API/makeRequest';
7
8class Home extends Component {
9 state = {10 data: null,11 }12
13 componentDidMount() {
14 fetch(url)
This issue is based on the organizational behavior pattern as developers prefer many things differently, e.g., vim over emacs or emacs over vim.
There are two styles to initialize state in React component class:
It can be fixed by using the alternate approach to the issue raised:
class Foo extends React.Component {
state = { bar: 0 }
render() {
return <div>Foo</div>
}
}
class Foo extends React.Component {
constructor(props) {
super(props)
this.state = { bar: 0 }
}
render() {
return <div>Foo</div>
}
}