# 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)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://refract.js.org/api/compose.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
