All Projects → gregberge → Recompact

gregberge / Recompact

Licence: mit
⚛ A set of React higher-order components utilities. Drop-in replacement for recompose.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Recompact

Flagged
Feature Flags for React made easy with hooks, HOC and Render Props
Stars: ✭ 97 (-76.85%)
Mutual labels:  higher-order-component, hoc
Neoform
✅ React form state management and validation
Stars: ✭ 162 (-61.34%)
Mutual labels:  higher-order-component, hoc
Next Nprogress
Next.js HOC to integrate NProgress inside your app
Stars: ✭ 145 (-65.39%)
Mutual labels:  higher-order-component, hoc
Hocs
🍱 Higher-Order Components for React
Stars: ✭ 1,784 (+325.78%)
Mutual labels:  higher-order-component, hoc
addhoc
Handy little helper to create proper React HOC functions complete with hoisted statics and forwarded refs
Stars: ✭ 40 (-90.45%)
Mutual labels:  higher-order-component, hoc
Incompose
A inferno utility belt for function components and higher-order components
Stars: ✭ 76 (-81.86%)
Mutual labels:  higher-order-component, hoc
react-drip-form
☕ HoC based React forms state manager, Support for validation and normalization.
Stars: ✭ 66 (-84.25%)
Mutual labels:  higher-order-component, hoc
React Bps
🔱 Create breakpoints to your component props
Stars: ✭ 64 (-84.73%)
Mutual labels:  higher-order-component, hoc
react-app-loader
Production ready library for handling Microfrontends
Stars: ✭ 75 (-82.1%)
Mutual labels:  higher-order-component, hoc
React With Direction
Components to provide and consume RTL or LTR direction in React
Stars: ✭ 176 (-58%)
Mutual labels:  higher-order-component, hoc
React Nprogress
⌛️ A React primitive for building slim progress bars.
Stars: ✭ 173 (-58.71%)
Mutual labels:  higher-order-component, hoc
react-table-hoc-draggable-columns
ReactTable HOC for draggable columns
Stars: ✭ 27 (-93.56%)
Mutual labels:  higher-order-component, hoc
rrx
⚛️ Minimal React router using higher order components
Stars: ✭ 69 (-83.53%)
Mutual labels:  higher-order-component, hoc
react-animation-frame
A React higher-order component that invokes a callback in a wrapped component via requestAnimationFrame
Stars: ✭ 47 (-88.78%)
Mutual labels:  higher-order-component, hoc
hoc-element-table
📦 A Vue 3.x Table Component built on Webpack 5
Stars: ✭ 26 (-93.79%)
Mutual labels:  hoc
hook-into-props
Tiny HoC to use React hooks with class components.
Stars: ✭ 44 (-89.5%)
Mutual labels:  higher-order-component
react-example-paginated-list-infinite-scroll
Follow a React tutorial series with three parts to build a powerful component in React.
Stars: ✭ 43 (-89.74%)
Mutual labels:  higher-order-component
nextjs-redux-instagram
🌏 The simple Instagram was written by next.js & redux-saga & recompose
Stars: ✭ 48 (-88.54%)
Mutual labels:  higher-order-component
React Router Breadcrumbs Hoc
tiny, flexible, HOC for rendering route breadcrumbs with react-router v4 & 5
Stars: ✭ 276 (-34.13%)
Mutual labels:  hoc
next-utils
🥩 🍳 A set of Next.js HoC utilities to make your life easier
Stars: ✭ 30 (-92.84%)
Mutual labels:  hoc
Recompact

Build Status codecov

Recompact is a set of React higher-order components for reactive programming. It's a drop-in replacement of Recompose with several enhancements.

State of recompact

React has introduced React hooks: a new way to manage state and lifecycle in React. It solves most of use case that recompact was trying to solve. That's why recompact is now deprecated and not actively maintained. The project will remain published on npm but it does not accept new issues and it won't evolve any more. If you use it, you are encouraged to migrate to hooks, if you don't use it yet, then do not install it. If you really like it, feel free to fork it!

Installation and Usage

To install the stable version:

yarn add recompact

and to use it in your code:

import recompact from 'recompact'

Optimizing bundle size

babel-plugin-lodash

The best way to reduce build size is to use babel-plugin-lodash. It can be used with other libraries than lodash, just like this:

.babelrc

{
  "plugins": [
    ["lodash", { "id": "recompact" }],
  ]
}

Transforms

import recompact from 'recompact'
import { pure, withProps } from 'recompact'

const enhance = recompact.compose(
  withProps({ className: 'beautiful' }),
  pure,
)

roughly to

import _compose from 'recompact/compose'
import _pure from 'recompact/pure'
import _withProps from 'recompact/withProps'

const enhance = _compose(
  _withProps({ className: 'beautiful' }),
  _pure,
)

Tree shaking

Since tree shaking isn't ready yet to reduce build size efficiently, it is not supported in recompact.

Documentation

Benchmarks

Recompact vs. Recompose

Recompact is a drop-in replacement* for Recompose with better performance.

* Except for the callback of withState's state updater.

Flattened React components tree

You may have noticed the "compact" keyword in "Recompact". It's the main differences between Recompose and Recompact. Recompact compacts all higher-order components into a single one. It results in a flatter React tree. A flatter React tree has several advantages: performance improvement, better debugging (especially in React Developer Tools) and easier testing.

Let's take two components using composition, one using recompose and one using recompact.

The two components are similar, but if you take a look at the React component tree (using React Developer Tool), you can see that the component using recompact is flat:

recompact-vs-recompose

New methods

Recompact also features higher-order components that are not included in Recompose:

And some very specific higher-order components that give you a lot of power:

To learn more about how to use connectObs and withObs inside your project, please refer to this complete guide about connectObs and withObs.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].