> For the complete documentation index, see [llms.txt](https://refract.js.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://refract.js.org/api/compose.md).

# compose

Used for composing functions from right to left, it is a very useful utility for composing higher-order components in React, Inferno or Preact.

## Packages

`compose` is provided by our React, Inferno or Preact packages - `refract-*`, `refract-inferno-*`, `refract-preact-*`.

## Signature

`compose` will compose multiple function to create a function which takes a single argument.

```javascript
compose = (...functions) => arg => result
```

Using `compose` with three functions `f`, `g` and `h` is the equivalent of `arg => f(g(h(arg)))`

## Example

```javascript
import { connect } from 'react-redux'
import { withEffects, compose } from 'refract-rxjs'

const WrappedComponent = compose(
    connect(mapStateToProps, mapDispatchToProps),
    withEffects(aperture)
)(BaseComponent)
```
