Logics first. React later. The missing bridge between OOP and React: turn any class into a reactive source.
React is for UI — keep it that way.
use-less-react is designed to separate React from business logics, utilities and everything not strictly and intrinsically related to rendering UI.
We've all been there: wrapping all your logics in custom hooks and cascades of useEffect, useMemo, useCallback, useRef etc.
Just because we got used to it doesn't mean it's good. A UI library shouldn't interfere with the way you write logics - at any level.
Decouple your brain from React, for good. With use-less-react you will be able to:
- write plain JavaScript classes with OOP principles and whatever design pattern you may deem needed.
- keep React solely for UI rendering.
- make your code more reusable (for example SSR/CSR in Next.js)
- make your code easier to test (no need to install new dependencies just to be able to test a hook...)
- Make Classes Great Again 🦅😎 (...ok, now I'm kidding!)
use-less-react lets any class instance become reactive and usable in React, without polluting your business logic with hooks. Because not everything needs a hook.
npm install @dxbox/use-less-react- Client (client-side only: hooks and contexts):
import { useReactiveInstance, createGenericContext, ... } from '@dxbox/use-less-react/client';- Classes (wherever you want):
import { PubSub, PubSubMixin, Notifies, ... } from '@dxbox/use-less-react/classes';Check full documentation on the dedicated website!
MIT