
React
文章平均质量分 65
真的是沐白
前端开发
展开
-
React constructor中的super
class Checkbox extends React.Component { constructor(props) { super(props); this.state = { isOn: true }; } // ...}对于上面的类Checkbox来说,它的super是React.Component接下来我们依次讨论下列问题:1.如果不调用sup...原创 2018-12-07 11:14:45 · 357 阅读 · 0 评论 -
React是怎么判断组件是函数式的还是类式声明的
先来说下React组件的声明方式:// 1.函数式function Greeting (){}// 2.classclass Greeting extends Component{}我们在使用的时候不会关心组件的声明方式,但React会关心所以接下来就说下React是怎么判断组件是用哪种方式声明的一.在Component上直接加标记// Inside Reactc...原创 2018-12-09 16:52:11 · 1480 阅读 · 0 评论 -
JavaScript中class继承之后父级和子级原型的关系
class Component {}class Greeting extends Component {}上面的例子,Greeting继承Component意味着一. Greeting.__proto__ === Component二. Greeting.prototype.__proto__ === Component.prototype也就是说 new Greeting(...原创 2018-12-11 08:17:22 · 560 阅读 · 1 评论 -
React 的key详解
我们在学React的list章节的时候,一定会提到key这个属性,key是给React用的,主要是为了区分不同的组件,是组件的唯一标识,当我们没用设置key属性的时候,React会给出警告,并且会把数组的index作为组件的key值,所以说key对于组件是必不可少的,那有同学可能会问了,如果key这么重要的话,为什么我只在用数组的map方法返回的组件中用过key,其它组件我却没有用过,其实对于其它...原创 2018-12-24 20:11:23 · 1111 阅读 · 0 评论 -
react路由match.path和match.url的区别
match.path指的是返回当前组件所对应的pathmatch.url指的是当前组件真实的url如果还有些模糊,看下面的例子就明白了import React from "react";import { BrowserRouter as Router, Route, Link } from "react-router-dom";const App = () => ( ...原创 2019-02-03 14:25:49 · 4640 阅读 · 0 评论 -
Objects are not valid as a React child
自己写一个简单的React组件的时候,因为Objects are not valid as a React child (found: Sat Feb 23 2019 16:18:01 GMT+0800 (China Standard Time)). If you meant to render a collection of children, use an array instead....原创 2019-02-23 16:25:25 · 4790 阅读 · 1 评论