How to add materializecss in react?

0

I have a project made with asp.net core with the template of react and redux, install the packages from npm of materializecss, which I am already pointing your files of .css but I have the problem that I do not know where to include or call to the files .js of materialize.

It should be noted that I am new in development with react, therefore I do not handle very well how this kind of calls or imports should be handled.

I have the following in my code:

As you can see, comment the imports bootstrap% to include the materializecss css, but I do not know where I should put the .js since I could not find the bootstrap import js in the project I only have the package in node_modules

//import 'bootstrap/dist/css/bootstrap.css';
//import 'bootstrap/dist/css/bootstrap-theme.css';
import 'materialize-css/dist/css/materialize.css';
import './index.css';
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import { createBrowserHistory } from 'history';
import configureStore from './store/configureStore';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

import Media from './components/media';

// Create browser history to use in the Redux store
const baseUrl = document.getElementsByTagName('base') 
[0].getAttribute('href');
const history = createBrowserHistory({ basename: baseUrl });

// Get the application-wide store instance, prepopulating with state from the server where available.
const initialState = window.initialReduxState;
const store = configureStore(history, initialState);

const rootElement = document.getElementById('root');

//ReactDOM.render(
//  <Provider store={store}>
//    <ConnectedRouter history={history}>
//      <App />
//    </ConnectedRouter>
//  </Provider>,
//  rootElement);

render(
    <Media title="¿Qué es responsive Design?" author="vcasas"/>,
    rootElement);

registerServiceWorker();

And this would be my index.html file

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<base href="%PUBLIC_URL%/" />
<!--
  manifest.json provides metadata used when your web app is added to the
  homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
  Notice the use of %PUBLIC_URL% in the tags above.
  It will be replaced with the URL of the 'public' folder during the build.
  Only files inside the 'public' folder can be referenced from the HTML.

  Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
  work correctly both with client-side routing and a non-root public URL.
  Learn how to configure a non-root public URL by running 'npm run build'.
-->
<title>VirtualPOS</title>
 </head>
 <body>
<noscript>
  You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
  This HTML file is a template.
  If you open it directly in the browser, you will see an empty page.

  You can add webfonts, meta tags, or analytics to this file.
  The build step will place the bundled scripts into the <body> tag.

  To begin the development, run 'npm start' or 'yarn start'.
  To create a production bundle, use 'npm run build' or 'yarn build'.
-->
 </body>
</html>
    
asked by vcasas 22.11.2018 в 13:27
source

1 answer

-3

You can use the React Materialize library or import CSS and Javascript into your index.html. In this last option if you need JavaScript functionalities you should also include jQuery in your project.

To install React Materialize:

Using npm:

  

npm install --save react-materialize

Using yarn:

  

yarn add react-materialize

I hope it serves you.

    
answered by 22.11.2018 в 15:41