小编Key*_*oll的帖子

默认导出不是页面中的 React 组件:"/" NextJS

不知道为什么会出现错误,这是我的 index.js 和 App.js(默认导出)。我在 app.js 中使用了导出默认值。

索引.js:

import "./index.css";
import App from "./App";
import "bootstrap/dist/css/bootstrap.css";
import "font-awesome/css/font-awesome.css";
<App />;
Run Code Online (Sandbox Code Playgroud)

应用程序.js

import React, { Component } from "react";
import { ToastContainer } from "react-toastify";
import NavBar from "../components/navBar";
import auth from "../services/authService";
import "react-toastify/dist/ReactToastify.css";
import "./App.css";

class App extends Component {
  state = {};

  componentDidMount() {
    const user = auth.getCurrentUser();
    this.setState({ user });
  }

  render() {
    const { user } = this.state;

    return (
      <React.Fragment>
        <ToastContainer />
        <NavBar user={user} />
      </React.Fragment> …
Run Code Online (Sandbox Code Playgroud)

reactjs next.js

4
推荐指数
5
解决办法
1万
查看次数

不变式失败:浏览器历史记录需要一个 DOM

我的 App.js(经过简化但仍然会出现这么多错误。)

import React, { Component } from "react";

class App extends Component {
  state = {};

  componentDidMount() {
    this.setState({ user });
  }
}

export default App;
Run Code Online (Sandbox Code Playgroud)

我现在更新了我的 index.js:

import React from "react";
import { BrowserRouter } from "react-router-dom";
import App from "./App";

const Index = () => (
  <BrowserRouter>
    <App />
  </BrowserRouter>
);

export default Index;
Run Code Online (Sandbox Code Playgroud)

它给出了错误 Invariant failed: Browser history needs a DOM

reactjs next.js

3
推荐指数
1
解决办法
3005
查看次数

NextJS 模块解析失败:意外字符“@”(7:0)

[ error ] ./node_modules/font-awesome/css/font-awesome.css 7:0
Module parse failed: Unexpected character '@' (7:0)
You may need an appropriate loader to handle this file type, currently no loaders are 
configured to process this file. See https://webpack.js.org/concepts#loaders
| /* FONT PATH
|  * -------------------------- */
> @font-face {
|   font-family: 'FontAwesome';
|   src: url('../fonts/fontawesome-webfont.eot?v=4.7.0');
Run Code Online (Sandbox Code Playgroud)

我已经安装了 next-css,我的 next.config.json 是:

const withCSS = require("@zeit/next-css");
module.exports = withCSS({});
Run Code Online (Sandbox Code Playgroud)

node.js next.js

1
推荐指数
1
解决办法
8439
查看次数

标签 统计

next.js ×3

reactjs ×2

node.js ×1