1

I'm fairly new to react and I'm adding styling to my react components so it displays a list of movies. The CSS file I created is not loading into the application when imported. At this point it only works with inline styling and I'd rather not do that. Does anybody have an idea why this isn't working?

Movies.css:

.MoviesContainer {
  display: "flex";
  justify-content: "space-evenly";
  flex-wrap: "wrap";
}
import "./Movies.css"

const Movies = () => {
 return (
    <div>
      <Search onChange={(value) => setInput(value)} />
      <div className="MoviesContainer">
        <Film list={movies}/>
      </div>
    </div>
  )
}
4
  • Ryan, can you provide more details? Questions that arise from my head when I see these snippets are: are you importing the css file into the component's file? Have you installed and configured the appropriate loaders to handle css files? Commented Jun 14, 2020 at 21:10
  • @MarceloCardoso Sorry about that, but I haven't installed any loaders since I used create-react-app. I'm importing the css file into the components file. Commented Jun 14, 2020 at 21:25
  • Any console errors or warnings? If not, then it would seem as though the import of the .css file is working... is this the first CSS file you are importing, or are you successfully importing other CSS files in this same project? Commented Jun 15, 2020 at 1:40
  • @AlexanderNied it actually turned out to be a syntax mistake. The selector in my css file had property values in quotes when they shouldn't have been. Commented Jun 15, 2020 at 14:36

2 Answers 2

2

The issue was caused by a syntax mistake of having the values of the properties in "quotes".

Movies.css:

.MoviesContainer {
  display: "flex";
  justify-content: "space-evenly";
  flex-wrap: "wrap";
}

Should be:

Movies.css:

.MoviesContainer {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for following up by posting your solution! Don't forget to mark it as "accepted", so that others visiting this post are aware that this is the fix that worked in your specific case. Happy coding!
0

Your classname is 'MoviesContainer' in the CSS file and 'MovieContainer' in the js file.

If you fix that and import the file css file it should work.

1 Comment

Sorry that was a typo, I just updated the snippet a few moments ago.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.