I am working through a tutorial where they are using a styled-component
. The style is being assigned in the js file after the render and I am getting the Invalid hook call. This is my first react tutorial so I am struggling to just google the answer. Below is the code that I am running. The error only pops up when I call <MovieGrid>
. Any help would be appreciated
/* eslint react/no-did-mount-set-state: 0 */
import React, { Component } from 'react';
import styled from 'styled-components';
import Movie from './Movie';
class MoviesList extends Component {
state = {
movies: [],
}
async componentDidMount() {
try {
const res = await fetch('url');
const movies = await res.json();
this.setState({
movies: movies.results,
});
} catch (e) {
console.log(e);
}
}
render() {
return (
<MovieGrid>
{this.state.movies.map(movie => <Movie key={movie.id} movie={movie} />)}
</MovieGrid>
);
}
}
export default MoviesList;
const MovieGrid = styled.div`
display: grid;
padding: 1rem;
grid-template-columns: repeat(6, 1fr);
grid-row-gap: 1rem;
`;
const MovieGrid
to before the class and try? – Asphaltiteconst MovieGrid
just below the import statements and still getting the same error message – Demosthenes