0

Tengo un proyecto hecho con asp.net core con la plantilla de react y redux, instale los paquetes desde npm de materializecss, el cual ya estoy apuntando sus archivos de .css pero tengo el problema que no se donde incluir o llamar a los archivos .js de materialize.

Cabe señalar que soy nuevo en desarrollo con react, por ende no me manejo muy bien en como se debería manejar este tipo de calls o imports.

Tengo lo siguiente en mi código:

Como se puede ver, comente los imports de bootstrap para incluir el css de materializecss, pero no se en donde debo colocar el .js ya que tampoco pude encontrar el import js de bootstrap en el proyecto solo tengo el paquete en 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();

Y este seria mi archivo index.html

<!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>

1 respuesta 1

-3

Puedes usar la libreria React Materialize o importar el CSS y Javascript en tu index.html. En esta ultima opción si necesitas funcionalidades JavaScript tendrias que incluir jQuery también en tu proyecto.

Para instalar React Materialize:

Usando npm:

npm install --save react-materialize

Usando yarn:

yarn add react-materialize

Espero te sirva.

2
  • 1
    agregar en una respuesta solo enlaces se considera de baja calidad; dale editar y añade lo relevante del enlace aqui
    – user75901
    el 22 nov. 2018 a las 14:45
  • No es lo que estoy preguntando, favor leer bien.
    – vicasas
    el 22 nov. 2018 a las 18:58

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.