ref
摘要:【ref】 1、Callback Refs 最古老原始的,通过 ref={SetMethod} 来获取 ref的方法。 2、Creating Refs Callback refs 需要写很多 SetMethod,非常麻烦。最新的 React 已经推出了 Creating Refs,来减少 SetMe
阅读全文
React设置宽度的坑
摘要:【React设置宽度的坑】 我们知道通过ref可以获取DOM元素,通过style属性可以给此DOM元素添加样式。 但下面两行的赋值是无效的: 因为style中的width、height是有单位的,必须加上px才是有效的赋值。所以要改成下面这样
阅读全文
ReactCSSTransitionGroup
摘要:【ReactCSSTransitionGroup】 ReactCSSTransitionGroup is a high-level API based on ReactTransitionGroup and is an easy way to perform CSS transitions and
阅读全文
React Mixins
摘要:【React Mixins】 ES6 launched without any mixin support. Therefore, there is no support for mixins when you use React with ES6 classes. We also found nu
阅读全文
react input的几个坑
摘要:【react input的几个坑】 1、input标签中设置value后,input进入controlled模式,valuechange由自动变为手动,导致input无法编辑。如: <input value="xxx"/> // 导致无法编辑 解法:使用代码来对input.value赋值即可。如 t
阅读全文
create-react-app之Invalid Host Header
摘要:【create-react-app之Invalid Host Header】 1、When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because
阅读全文
使用Js控制ReactRouter路由
摘要:【使用Js控制ReactRouter路由】 首先引入PropTypes: 然后定义context的router属性: 最后,使用代码跳转即可。 goBack方法可以用于回退到前一页面。 参考: 1、https://facebook.github.io/react/docs/context.html
阅读全文
create-react-app之proxy
摘要:【create-react-app之proxy】 create-react-app可以用于一键创建web_client环境,默认使用webpack-dev-server。但在开发过程中,往往需要client/server配合调试。当我们需要将请求发送到自有服务器而非webpack-dev-serve
阅读全文
React中innerHTML的坑
摘要:【React中innerHTML的坑】 通过React Ref机制返回的对象,是一个阉割的DOM对象,并非原始DOM对象。比如,这个阉割版的DOM对象没有innerHTML对象。 上面的代码通过ref来获取一个dom对象,但这个对象是没有innerHTML属性的。 为了获取innerHTML,我们需
阅读全文
combineReducers
摘要:【combineReducers】 Redux provides a utility called combineReducers(). The following two diagram has the same effect. You could also give them different
阅读全文
React Context
摘要:【React Context】 1、Why Not To Use Context The vast majority of applications do not need to use context. 大多数应用不需要使用context。 If you want your application
阅读全文
propTypes
摘要:【propTypes】 React.PropTypes is deprecated as of React v15.5. Please use the prop-types library instead. You can define default values for your props b
阅读全文
Redux
摘要:【Redux】 1、Redux 的设计思想 (1)Web 应用是一个状态机,视图与状态是一一对应的。 (2)所有的状态,保存在一个对象里面。 2、Store Store 就是保存数据的地方,你可以把它看成一个容器。整个应用只能有一个 Store。 Redux 提供createStore这个函数,用来
阅读全文
Flux architecture
摘要:【Flux architecture】 Flux is a pattern for managing data flow in your application. The most important concept is that data flows in one direction. As w
阅读全文
React DevTools
摘要:【React DevTools】 在应用商店搜索安装。F12可打开。如果是react应用,在最右排会显示react标签. 参考:https://github.com/facebook/react-devtools
阅读全文
react+webpack+babel环境搭建
摘要:【react+webpack+babel环境搭建】 1、react官方文档推荐使用 babel-preset-react、babel-preset-es2015 两个perset。 Babel官方文档推荐使用 babel-preset-env。而不再推荐直接使用babel-preset-es2015
阅读全文
Typechecking With PropTypes
摘要:【Typechecking With PropTypes】 1、props类型检查 React has some built-in typechecking abilities. To run typechecking on the props for a component, you can as
阅读全文
JXS In Depth
摘要:【JXS In Depth】 1、Spread Attributes If you already have props as an object, and you want to pass it in JSX, you can use ... as a "spread" operator to p
阅读全文
Choosing the Type at Runtime
摘要:【Choosing the Type at Runtime】 You cannot use a general expression as the React element type. If you do want to use a general expression to indicate t
阅读全文
User-Defined Components Must Be Capitalized
摘要:【User-Defined Components Must Be Capitalized】 When an element type starts with a lowercase letter, it refers to a built-in component like<div> or <spa
阅读全文