我正在学习如何使用组件使用React。
我的页面工作正常,但是如果我将组件移动到另一个JS文件并试图导入它,我的页面将完全为空。
下面是注释掉导入的工作代码。
//import Header from "./Header.js"
//import Footer from "./Footer.js"
function Body () {
return (
<div>
<h1>Reasons I am excited to learn reac
我正在使用Next.js将我的CRA转换成一个SSR应用程序。我刚刚开始,已经遇到了一个简单的问题(我希望如此)。我能够使用index.js ()将数据直接从我的getInitialProps页面呈现给浏览器。显然,我不想在索引页面上设置我的整个应用程序。
我遇到的问题是试图将数据从子组件导入索引页。使用与我的工作示例相同的代码,我得到了可怕的"TypeError:无法读取未定义的“错误的属性'map‘。这个简单的导出/导入设置在反应上是不可做的。
下面是一个类似于我的代码的例子,在子组件中.
import Link from 'next/link'
impor
我有两个带有动态路由的页面(父页面和子页面),并且我只想在子页面中调用getServerSideProps()。第一页,[Post].js import React from 'react'
import PropTypes from 'prop-types'
import axios from 'axios'
import Index from './index'
const Post = ({ children, making }) => {
return (
<Index>
我正尝试在一个电子应用程序中使用,但在应用程序窗口中,我在chrome控制台中得到以下错误:
Uncaught TypeError: Cannot read property '_handle' of undefined
at file:///[...]/assets/js/bundle.js:38727:15
at Array.forEach (native)
at module.exports (file:///[...]/assets/js/bundle.js:38726:36)
at Object.<anonymous> (f
我有错误说
react.development.js:1476 Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking th
我是新的反应,我正在学习道具。我的道具没有在Events.js上显示颜色,我得到的是“我是一辆车”,而红色没有显示。
这是我的组件Welcome.js:
import React from 'react'
import ReactDOM from "react-dom";
function Welcome(props) {
return <h2>I am a {props.color} Car!</h2>;
}
ReactDOM.render(<Welcome color="red"/&g
我是新的反应和工作方式,通过如何使用‘道具’和‘状态’在网上课程。在线课程使用ES5,但我的IDE是为ES6设置的。我已经完成了对大多数例子的转换。但下面的情况令人费解。该示例运行良好,但我的ES6转换没有--页面呈现为空白。我看了一遍“可能已经有答案的问题”,但没有任何东西显示我遗漏了/mistake(S)。不过,我在其他更改上得到了语法上的验证。:)
我在App.js文件中的转换
import React, { Component } from 'react';
let green = '#39D1B4';
let yellow = '#FFD7
我是ReactJ的新手。在我的应用程序中,我插入了下面的代码来验证textArea,但是当我键入它时,它会抛出以下错误。
NewBrand.js:67 Uncaught TypeError: Cannot read property 'validateName' of undefined
at handleNameChange (NewBrand.js:67)
at TextArea._this.handleTextareaChange (TextArea.js:94)
at HTMLUnknownElement.callCall
我在控制台日志中没有定义,而不是在数据中。
My Index.js (页面文件)
import Head from "next/head";
import Link from "next/link";
import axios from "axios";
import Test from "../components/Test";
import styles from "../styles/Home.module.css";
function Home() {
return (
<
这是我使用React.js的第一个项目,我按照以下步骤创建Hello World ()
我在head标签中导入了React.js,但是为什么我的代码不能工作?index.html只是一个空白页面
index.html
<html>
<title>
My first project using React.js
</title>
<head>
<script src="https://unpkg.com/react@15/dist/react.js"></sc