react 引入组件
by Jake Moxey
杰克·莫西(Jake Moxey)
引入React负载—无头React组件,用于处理承诺状态和响应数据 (Introducing React Loads — A headless React component to handle promise states and response data)
简单,声明性和轻量级 (Simple, declarative, and lightweight)
背景 (Background)
There are so many methods to handle state in React right now. From local state to Redux, the new React Context API and new libraries such as Unstated and Copy Write. All these methods have great use cases, and there are no absolutes in which I’d drop one entirely in favour of another. Each of them have their situational benefits.
现在有很多方法可以在React中处理状态。 从本地状态到Redux ,新的React Context API 和 新的库,例如Unstated 和复制写 。 所有这些方法都有很好的用例,没有绝对的方法可以让我完全放弃另一种方法。 他们每个人都有自己的处境利益。
But I don’t want to get into the nitty gritty of React state management. Check out Kent C. Dodd’s excellent article about Application State Management for that.
但是我不想陷入React状态管理的棘手问题。 请查看Kent C. Dodd撰写的有关应用程序状态管理的出色文章。
Though I do want to touch on the case of handling loading and response state from a promise, for example HTTP requests and resource fetchers. A promise has three explicit states: pending,