最初发表于https://medium.com/dailyjs/applying-solid-principles-in-react-14905d9c5377 随着软件行业的发展和犯错,最佳实践和良好的软件设计原则出现并被概念化,以避免在未来重复同样的错误。尤其是面向对象编程 (OOP) 世界是这些最佳实践的金矿,而 SOLID 无疑是最具影响力的之一。 SOLID 是一个首字母缩略词,...
SOLID 原则是面向对象设计的五个基本原则,旨在帮助开发者创建可维护、可扩展和可重用的代码。虽然这些原则起源于面向对象编程,但它们可以有效地应用于JavaScript。本文通过JS中的真实示例解释了每个原则。 1.单一职责原则 (Single Responsibility Principle, SRP) ...
useGetRemoteData.js- 负责过滤远程数据 useHttpGetrequest.js- 负责 HTTP 调用 LoadingReducer.js- 复杂的状态管理 当然,我们可以改进很多其他的东西,但是这应该是一个很好的起点。 总结 这是一个简单的演示,演示如何减少每个文件中的代码量,并使用 SOLID 的强大功能创建漂亮的可重用组件。 本文为译文,原文链接:ht...
import {useEffect, useReducer, useState} from "react"; import {loadingReducer} from "./LoadingReducer"; const initialState = { isLoading: true }; export const useHttpGetRequest = (URL) => { const [users , setUsers] = useState([]) const [state, dispatch] = useReducer(loadingReducer, in...
Amy认为,React hooks 不尊重SOLID架构原则。我不太同意,但我承认,在网上找到的大多数例子都是简化的,不一定能突出一个好的架构。 Applying SOLID principles in React 几乎是对上述文章的直接回答,即使SOLID的应用在这里被更广泛地覆盖(components + hooks)。注意:不要犹豫,使用React上下文进行依赖注入。 拓展阅读 Av...
本文为译文,原文链接:https://betterprogramming.pub/how-to-apply-solid-principles-to-clean-your-code-in-react-cdfd5e0a9cea[1] 参考资料 [1] https://betterprogramming.pub/how-to-apply-solid-principles-to-clean-your-code-in-react-cdfd5e0a9cea:https://betterprogramming.pub/how-to-apply-solid...
Principios SOLID en React.js (Buenas prácticas) con ejemplos prácticos SOLID es el acrónimo de los siguientes 5 principios: Single Responsibility Principle (SRP) Open-Closed Principle (OCP) Liskov Substitution Principle (LSP) Interface Segregation Principle (ISP) Dependency Inversion Principle (DIP...
Too Long; Didn't ReadReact’s component-based architecture makes it an excellent candidate for SOLID principles. SOLID Principles help developers write scalable, maintainable, and robust software. In this article, we’ll break down each of the five principles and how to apply them in React. ...
Recommended resources SOLID Principles Succinctly Related blogs What’s New in Essential JS 2: 2023 Volume 1 Syncfusion Essential Studio® 2023 Volume 1 Is Here! Integrating JavaScript Scheduler with PHP and MySQL for Dynamic CRUD Operations
react api typescript rest solid nextjs openapi rpc fastify nestjs react-query Updated May 26, 2025 TypeScript inokawa / virtua Sponsor Star 2.8k Code Issues Pull requests Discussions A zero-config, fast and small (~3kB) virtual list (and grid) component for React, Vue, Solid and ...