使用jsx错误时反应必须在范围内

时间:2020-06-29 21:36:15

标签: reactjs

非常简单的代码,我检查了React拼写,导入了ReactDom,请指导我有关错误的信息。我是时尚界的新手。


import React, { Component } from "react";
import "./App.css";
import { Cardlist } from "./components/cardlist/cardlist.component.jsx";

class App extends Component {
  constructor() {
    super();
    this.state = {
      string: "Hello before",
    };
  }

  render() {
    return (
      <div className="App">
        <p>{this.state.string}</p>
        <button onClick={() => this.setState({ string: "After text" })}>
          Change text
        </button>
        <Cardlist name="this was prop" />
      </div>
    );
  }
}

export default App;

卡片列表组件

import react from "react";

export const Cardlist = (props) => {
  console.log(props);
  return <div>COngratulations</div>;
};

1 个答案:

答案 0 :(得分:0)

尝试将reactReact的{​​{1}}更改为first line吗?