I'm new to react hooks, and I'm having a hard time to convert this class, into react hooks with ES6 syntax. could somone please help me. here is my coude...
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import { fetchMovie, setLoading } from '../../actions/searchActions';
import Spinner from '../layout/Spinner';
export class Movie extends Component {
componentDidMount() {
this.props.fetchMovie(this.props.match.params.id);
this.props.setLoading();
}
render() {
const { loading, movie } = this.props;
let movieInfo = (
<div className="container">
jsx......
</div>
);
let content = loading ? <Spinner /> : movieInfo;
return <div>{content}</div>;
}
}
const mapStateToProps = state => ({
loading: state.movies.loading,
movie: state.movies.movie
});
export default connect(
mapStateToProps,
{ fetchMovie, setLoading }
)(Movie);