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 · 403 阅读 · 0 评论 -
React是怎么判断组件是函数式的还是类式声明的
先来说下React组件的声明方式: // 1.函数式 function Greeting (){} // 2.class class Greeting extends Component{} 我们在使用的时候不会关心组件的声明方式,但React会关心 所以接下来就说下React是怎么判断组件是用哪种方式声明的 一.在Component上直接加标记 // Inside React c...原创 2018-12-09 16:52:11 · 1514 阅读 · 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 · 606 阅读 · 1 评论 -
React 的key详解
我们在学React的list章节的时候,一定会提到key这个属性,key是给React用的,主要是为了区分不同的组件,是组件的唯一标识,当我们没用设置key属性的时候,React会给出警告,并且会把数组的index作为组件的key值,所以说key对于组件是必不可少的,那有同学可能会问了,如果key这么重要的话,为什么我只在用数组的map方法返回的组件中用过key,其它组件我却没有用过,其实对于其它...原创 2018-12-24 20:11:23 · 1153 阅读 · 0 评论 -
react路由match.path和match.url的区别
match.path指的是返回当前组件所对应的path match.url指的是当前组件真实的url 如果还有些模糊,看下面的例子就明白了 import React from "react"; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; const App = () => ( ...原创 2019-02-03 14:25:49 · 4689 阅读 · 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 · 4815 阅读 · 1 评论
分享