All Projects β†’ wikiwi β†’ reassemble

wikiwi / reassemble

Licence: MIT license
Fast Library for the Composition of React Higher-Order-Components

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to reassemble

react-compose-events
A Higher-Order Component factory to attach outside event listeners
Stars: ✭ 25 (-62.69%)
Mutual labels:  composition, recompose
nextjs-redux-instagram
🌏 The simple Instagram was written by next.js & redux-saga & recompose
Stars: ✭ 48 (-28.36%)
Mutual labels:  higher-order-component, recompose
Learning Recompose
Composition is a beautiful thing. Let's learn why, using Recompose.
Stars: ✭ 18 (-73.13%)
Mutual labels:  composition, higher-order-component
Hocs
🍱 Higher-Order Components for React
Stars: ✭ 1,784 (+2562.69%)
Mutual labels:  higher-order-component, recompose
Refluent
A chainable & composable alternative React component API.
Stars: ✭ 75 (+11.94%)
Mutual labels:  composition, higher-order-component
rgxp
Regular Expression Collection (ReactJS, Redux, React Router, Recompose, NodeJS, Express)
Stars: ✭ 62 (-7.46%)
Mutual labels:  recompose
firebase-ignite
Firebase PWA Boilerplate
Stars: ✭ 12 (-82.09%)
Mutual labels:  recompose
react-native-smooth-pull-to-refresh
Custom pull to refresh component for React Native
Stars: ✭ 36 (-46.27%)
Mutual labels:  recompose
vuo
A realtime visual programming language for interactive media.
Stars: ✭ 103 (+53.73%)
Mutual labels:  composition
do
Simplest way to manage asynchronicity
Stars: ✭ 33 (-50.75%)
Mutual labels:  composition
HoaLibrary-Max
πŸ”‰ HoaLibrary for Max
Stars: ✭ 70 (+4.48%)
Mutual labels:  composition
clean-code-javascript-ko
πŸ› Clean Code concepts adapted for JavaScript - ν•œκΈ€ λ²ˆμ—­νŒ πŸ‡°πŸ‡·
Stars: ✭ 1,767 (+2537.31%)
Mutual labels:  composition
Modular2Recycler
ModularΒ²Recycler is a RecyclerView.Adapter that is modular squared.
Stars: ✭ 72 (+7.46%)
Mutual labels:  composition
react-portalgun
Lightweight portal system for React. Mega seeds included πŸ”«
Stars: ✭ 75 (+11.94%)
Mutual labels:  higher-order-component
react-native-tooltip-view
A deadly simple tooltip view that you can put whatever you want πŸŽ‰
Stars: ✭ 18 (-73.13%)
Mutual labels:  recompose
vesselize
β›΅ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-67.16%)
Mutual labels:  composition
UnderstandingLanguageExt
This is a tutorial that aims to demonstrate the practical fundamentals behind using LanguageExt in a fashion though step-by-step tutorials which introduce and then build up on concepts.
Stars: ✭ 73 (+8.96%)
Mutual labels:  composition
vue2-helpers
πŸ”§ A util package to use Vue 2 with Composition API easily
Stars: ✭ 64 (-4.48%)
Mutual labels:  composition
Edward-the-App
Write your first novel with the world's most helpful writing tool. (Out of business as of Dec 2021)
Stars: ✭ 55 (-17.91%)
Mutual labels:  composition
react-table-hoc-draggable-columns
ReactTable HOC for draggable columns
Stars: ✭ 27 (-59.7%)
Mutual labels:  higher-order-component

reassemble

reassemble is a library for the composition of React Higher-Order-Components optimized for performance.

NPM Version Widget Build Status Widget Coverage Widget

reassemble vs recompose

reassemble is very similar to recompose. Conceptually both projects differ in such way that recompose uses HOCs as their building blocks, whereas reassemble uses Composables which are just a collection of callbacks. Most noticeably using reassemble only results in a single Higher-Order-Component and thus has a significant higher performance. It also solves the problem of Dev Tools Ballooning which is an issue in recompose.

Using recompose together with reassemble

Both projects are not mutual exclusive but reassemble can be used perfectly together with recompose. In the end reassemble just produces a Higher-Order-Component that fits in nicely with the composition tools of recompose.

Performance

At the moment recompose is a bit faster in simple compositions (though we plan to close this gap) and reassemble performs better in complex composition.

Check out current benchmarks

Installation

npm install reassemble --save

Usage

import { assemble, withState, mapProps } from "reassemble"

const enhance = assemble(
  withState(/*...args*/),
  mapProps(/*...args*/),
);
const EnhancedComponent = enhance(BaseComponent);

Note: assemble is also exported with the alias compose to allow easy transition from recompose to reassemble

Size optimization

reassemble exports also as ES6 modules and as such tree shaking (e.g. with webpack 2) can be used to effectively reduce file size.

Without tree shaking you can import the modules explicitly:

import mapProps from "reassemble/lib/mapProps"
import withState from "reassemble/lib/withState"

And for ES5 projects:

const mapProps = require("reassemble/cjs/mapProps").mapProps
const withState = require("reassemble/cjs/withState").withState

Combining

Multiple Composables can be combined into one using combine() which makes it easy to define your own:

export const withClickCounter = combine(
  withState('counter', 'setCounter', 0),
  withHandlers({
    onClick: ({counter, setCounter}) => setCounter(counter + 1),
  }),
);

This is also useful for some Composables like branch that takes another Composable as an argument.

Support for Symbols

Most of the Composables supports the use of ES6 Symbols. You can use Symbols to pass hidden props among your Composables.

* In some cases TypeScript users will lose type information.

Note for TypeScript users

reassemble is written in TypeScript and as such comes with its own definitions. They do not follow the same type definitions as recompose so some manual work is required here.

Support of recompose HOCs as Composables

Name Support Remarks
branch βœ…
defaultProps βœ…
flattenProps βœ…
getContext βœ…
lifecycle ❌ Use Lifecycle Composables
mapProps βœ…
mapPropsStream ❌ File an issue if you really need this
onlyUpdateForKeys βœ…
onlyUpdateForPropTypes ❌ Use onlyUpdateForKeys instead
renameProp βœ…
renameProps βœ…
renderComponent βœ…
renderNothing βœ…
setDisplayName βœ…
setPropTypes βœ…
setStatic βœ…
shouldUpdate βœ…
pure βœ…
withContext βœ… Context will not be available in other Composables of the same Component
withHandlers βœ…
withProps βœ…
withPropsOnChange βœ…
withReducer βœ…
withState βœ…
toClass βœ…

Composables introduced by reassemble

debug()

debug(callback: (props) => void): Composable

Runs callback with current props. Defaults to logging to the console.

noOp

noOp: Composable

omitProps()

omitProps(...keys: string[]): Composable

Omit selected props.

isolate()

isolate(...composables: Composable[]): Composable

Runs passed Composables in isolation: any props created will be reverted. Use with integrate() to selectively keep props.

isolate(
  withProps({
    a: 1,
    b: 2,
  }),
  integrate("b"),
)
// { b: 3 }

integrate()

integrate(...keys: string[]): Composable

Selectively keep props that are otherwise reverted in isolate().

Lifecycle

Warning: Lifecycle Composables are still experimental.

onWillMount()

onWillMount(props): Composable

Called during lifecycle componentWillMount()

onDidMount()

onDidMount(props): Composable

Called during lifecycle componentDidMount()

onWillUnmount()

onWillUnmount(props): Composable

Called during lifecycle componentWillUnmount()

onWillReceiveProps()

onWillReceiveProps(prevProps, nextProps): Composable

Called during lifecycle componentWillReceiveProps() and when state changes because some props are derived from state.

onWillUpdate()

onWillUpdate(prevProps, nextProps): Composable

Called during lifecycle componentWillUpdate()

onDidUpdate()

onDidUpdate(prevProps, nextProps): Composable

Called during lifecycle componentDidUpdate()

Roadmap

  • Compatibility with React Fiber
  • Improve Lifecycle handling
  • More performance optimizations
  • More tests

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].