N
N
Nikita Shchypylov2018-04-09 22:30:26
React
Nikita Shchypylov, 2018-04-09 22:30:26

Why is the webpack config not loading when using Next.js?

Hi everyone, I'm working with React/Redux/Next.js. First I created a React / Redux base, now I started integrating Next. Changed package.json :

"start": "webpack-dashboard -- webpack-dev-server --mode development --open --hot",

I imported the
"start": "next",
App.js component into pages/index.js :
import React from "react";
import App from "../src/containers/App";

const Index = ({}) => (
  <div>
    <App />
  </div>
);

export default Index;

and returned:
Error in ./index.scss
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type. | .preview { | min-width: 100vw; | min-height: 100vh;

app.js :
import React, { Component } from "react";
import { connect } from "react-redux";
import { initAction } from "../../actions/index";
import "./index.scss";

class App extends Component {
  componentWillMount() {
    const initActionData = {
      hello: "world"
    };
    this.props.initAction(initActionData);
  }

  state = {
    preview: "img/index.jpg"
  };

  render() {
    const { preview } = this.state;
    return (
      <div className="preview" style={{backgroundImage: `url(${preview})`}} />
    );
  }
}
const mapDispatchToProps = {
  initAction
};
const mapStateToProps = state => {
  return {
    init: state.init
  };
};
export default connect(mapStateToProps, mapDispatchToProps)(App);

Didn't work with Next.js before. How to treat this? And how much more will come up during integration?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question