在 reducer 中,都是返回一个新对象,否则组件是不会更新 ui 的。而返回新对象,可以:
Object.assign
:比较 hack,每次新生成一个对象...state
- immutable.js
- 在入口文件(app.js)引入全局 css (
:global(.xxx){...}
),.xxx
不会被解析成 hash,可以在组件中className="xxx"
使用 - 本地css在组件(demo.js)中引入局部 css (
.yyy{...}
) ,在组件中styleName="yyy" 使用
common.css: global-style
:global(.xxx) {
...
yarn add xxx
添加新的 package,同时更新package.json
、yarn.lock
yarn upgrade xxx
更新 package,同时更新package.json
、yarn.lock
这样操作过后,我们把 yarn.lock
push 到代码仓库中
团队使用 Yarn 来管理模块依赖,这样只能保证大家的 yarn.lock
是一致的,但不能保证大家的 node_modules
是一致的(因为 node_modules
并不在版本库里)。要是有人升级了模块,别人拿到了新的 yarn.lock
,但是本地的 node_modules
里的模块仍然是旧的。
// es6
export var foo = 'foo';
setTimeout(() => foo = 'baz', 500);
// main
import {foo} from './t.js';
console.log(foo); // foo
setTimeout(() => console.log(foo), 500); // baz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unbind some default keybindings | |
unbind C-b | |
# set prefix key to ctrl-q | |
set -g prefix C-q | |
# lower command delay | |
set -sg escape-time 1 | |
# start first window and pane at 1, not zero |
一篇讨论 webpack 和 rollup 的文章 https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c
pkg.module 也很重要
- throttle 定义了一个函数一段时间内的最多执行次数,比如『执行这个函数最多每100ms执行一次』
- debounce 定义了一个函数在一定时间过去也没有被调用。比如『执行这个函数在没有被调用的100ms之后』
var throttle = function(fn, delay){
var last = 0
return function() {