blogs-of-patrickg's People
blogs-of-patrickg's Issues
analyses of project generated by create-react-app
config文件夹下内容
env.js
运用到这个文件的地方:俩webpack配置文件,仨启动文件(build, start, test)
.filter(Boolean)
代表的是筛选非负值的一种方式
利用了dotenv和dotenv-expand将文件系统中的文件(.env.xxx)所有环境变量注入到了真实的环境变量中。
最终导出的这个方法:getClientEnvironment将所有预设的和自定义的环境变量,以对象的形式导了出来。
待补充
小册【React实战:设计模式和最佳实践】要点
第一章
组件可以实现副作用,不一定非要render一些东西,可以用来获取数据。
第二章
在设计 React 组件时,要注意以下原则:
保持接口小,props 数量要少;(组件的规模要小,实现的功能要更加具体)
根据数据边界来划分组件,充分利用组合(composition);
把 state 往上层组件提取,让下层组件只需要实现为纯函数。
不要总是使用renderXXX的方式,多创建子组件更好,能够防止renderXXX中访问同样的props和state。
有些顺序不会改变的数组,可以用index作为key传入循环或者map。
另一种初始化类构造函数的方式,super(...arguments),这样可以兼容过去和未来的react版本的构造函数。
可以利用属性初始化的方法来初始化类的成员变量。
例如不在constructor中用this.的方式而是直接在类中用state={}的方式来定义这个类所拥有的属性。
写内联样式或者箭头函数会使得对象或者函数重新创建,使得子组件再次渲染,且无法通过shouldComponentUpdate方法来避免重新渲染。
一个功能的各个组成部分应该有自己的专属源代码文件。
第十章
用 Jest;
用 Enzyme;
保持 100% 的代码覆盖率。
jest的运行环境是自己的一个进程创建的,用例之间互相不影响。
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.