Skip to content

React 设计理念

什么是 react 认为好的代码?

React 代码中如何应用这些原则?

设计原则

  • Separation of Concerms 关注分离
  • High Cohesion,Loose Coupling 高内聚低耦合
  • K.I.S.S.(Keep it Simple,Stupid)
  • Performance

Abstraction

No abstraction > Wrong abstraction

Only abstraction to solve bugs

Remove as much complexity as you add

API

保证可组合性(compose)

composable Minimal API surface

Minimize application state and minimize side --effects

UI before API

Absorb the complexity

Naming

  • Consistent 一致性
  • Intuitive 直觉易懂
  • 尽量不缩写
  • 尽量不要简写

前端 UI 框架简史

React

best practices sparation concerms 关注分离 高内聚 低耦合

  1. 拥抱纯函数和不可变数据结构;
  2. 明确组件化和状态管理的方向;
  3. 引入 Hooks 解决状态管理和副作用问题,并非单纯的应用函数式编程原则。

如有转载或 CV 的请标注本站原文地址