Skip to content Skip to sidebar Skip to footer

Can't Import Materialize Css Js React

Good morning everyone, I've been struggling to get materialize css to work on my react-app, specifically, the Javascript files. I've tried multiple ways, but this is the one I thin

Solution 1:

You need to add your full path from npm module into your entry point file for webpack to utilize your css...

here is an example in a typical create-react-app using Index.js or what ever your calling it if you are doing your own react boilerplate.

Index.js

importReactfrom'react';
importReactDOM from'react-dom';
import'materialize-css/dist/css/materialize.min.css'; // <---importAppfrom'./components/App';

ReactDOM.render(<App />, document.getElementById('root'));

Once this is done your components will be able to have access to the css properties. I also recommend you install the npm i -S materialize-css@next so you can use JS components without needing JQuery

Solution 2:

using jquery with react is not recommended at all if you trying to use material how about using a library like

material-ui install it by using

npm i material-ui --save

and you can follow the example here for dialog which is basically a modal dialog in material ui

Post a Comment for "Can't Import Materialize Css Js React"