React Clean Architecture
See how React Clean Architecture helps to write Clean, Structured, Modularized and Best Coding Practices for React Developers.
Hello Developers! Many of us use various design patterns with React Development to make React Apps more clean, clearly understandable, and more structured. But still we are facing issues with coding standards, we changed at one place and it breaks at another place. Is there any resolution for this? Yes, Try React Clean Architecture!
Quick Highlights — React Clean Architecture — which makes your code more structured, clean and anyone can easily take over your code and start working with you. So Let’s continue next. Which include everything API, State Management (Redux, Redux Saga), Storybook, Utilities, Component/Container and you can add more relevant features in defined structure hierarchy.
React Clean Architecture Covered -
│ ├── application
│ │ ├── common
│ │ ├── filters
│ │ ├── logger
│ │ ├── models
│ │ ├── persist
│ │ ├── plugins
│ │ ├── store
│ ├── infrastructure
│ │ ├── api(services)
│ │ ├── components (common components)
│ ├── presentation
│ │ ├── container
│ │ ├── component
Ignite — React Native Boilerplate
Discover Ignite — React Native Boilerplate for Expo & React Native, explore pre-setup libraries like React Navigation…
Application directory contains the State Management and Common utilities functions and constants. For State Management — I have used Redux Rematch, you can use Redux, Redux Saga, MobX State Management. For Common — I have used Fonts, Colours, Global Constants and Common Functions.
Let’s check some parts of Rematch and Understand what it does and what it means.
Here, I am initialise Redux Store, to initialise Redux Store we require models, plugins, middleware (optional).
PlugIns itself means to add some value to Redux Store.Here, we are using Loading PlugIns means it will show loading indicator while API is fetching data. So we can show Loader to user, once data is fetched Loading plugin update loading State and based on that we can hide loaders in components.
Persist itself means to Persist something, Here, it will persist Rematch Store. To create persist store it will take few argument, key, whitelist (model — save in persist store), blacklist (model — not saved in persist store), version — help while upgrading application, storage — AsyncStorage (store persist store in AsyncStorage), transform — contains — filters which applied while persist store.
Models will contain State, Reducer, Effect (Actions).
Here, You can define your Global Constant, Common Files — Fonts, FontSize, Device Specification, Colours many more as per custom solution.
Let’s check some parts of Infrastructure and Understand what it does and what it means.
Components (Common Components) -
Presentation contains Component/Container. Component return design of your component, While Container contain wrapper of Component, HOC Wrapper Of Connect (Redux) to use Redux Store | Props into Components.
Let’s check some parts of Component/Container, what it does and what it means.
Thanks for reading Article! || Read More Technical Articles
KPITENG | DIGITAL TRANSFORMATION
www.kpiteng.com || email@example.com