# compose

[**Redux**](https://redux.js.org/)

[Getting Started](https://redux.js.org/introduction/getting-started)[Tutorial](https://redux.js.org/tutorials/essentials/part-1-overview-concepts)[API](https://redux.js.org/api/api-reference)[FAQ](https://redux.js.org/faq)[Best Practices](https://redux.js.org/style-guide/style-guide)[GitHub](https://www.github.com/reduxjs/redux)[Need help?](https://redux.js.org/introduction/getting-started#help-and-discussion)

🌜

🌞

Search

[**Redux**](https://redux.js.org/)

* [Getting Started](https://redux.js.org/introduction/getting-started)
* [Tutorial](https://redux.js.org/tutorials/essentials/part-1-overview-concepts)
* [API](https://redux.js.org/api/api-reference)
* [FAQ](https://redux.js.org/faq)
* [Best Practices](https://redux.js.org/style-guide/style-guide)
* [GitHub](https://www.github.com/reduxjs/redux)
* [Need help?](https://redux.js.org/introduction/getting-started#help-and-discussion)
* [Introduction](#!)
  * [Getting Started with Redux](https://redux.js.org/introduction/getting-started)
  * [Installation](https://redux.js.org/introduction/installation)
  * [Core Concepts](https://redux.js.org/introduction/core-concepts)
  * [Learning Resources](https://redux.js.org/introduction/learning-resources)
  * [Ecosystem](https://redux.js.org/introduction/ecosystem)
  * [Examples](https://redux.js.org/introduction/examples)
* [Tutorials](#!)
  * [Tutorials Index](https://redux.js.org/tutorials/index)
  * [Quick Start](https://redux.js.org/tutorials/quick-start)
  * [TypeScript Quick Start](https://redux.js.org/tutorials/typescript-quick-start)
  * [Redux Essentials](#!)
    * [Redux Overview and Concepts](https://redux.js.org/tutorials/essentials/part-1-overview-concepts)
    * [Redux App Structure](https://redux.js.org/tutorials/essentials/part-2-app-structure)
    * [Basic Redux Data Flow](https://redux.js.org/tutorials/essentials/part-3-data-flow)
    * [Using Redux Data](https://redux.js.org/tutorials/essentials/part-4-using-data)
    * [Async Logic and Data Fetching](https://redux.js.org/tutorials/essentials/part-5-async-logic)
    * [Performance and Normalizing Data](https://redux.js.org/tutorials/essentials/part-6-performance-normalization)
  * [Redux Fundamentals](#!)
    * [Redux Overview](https://redux.js.org/tutorials/fundamentals/part-1-overview)
    * [Redux Concepts and Data Flow](https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow)
    * [State, Actions, and Reducers](https://redux.js.org/tutorials/fundamentals/part-3-state-actions-reducers)
    * [Store](https://redux.js.org/tutorials/fundamentals/part-4-store)
    * [UI and React](https://redux.js.org/tutorials/fundamentals/part-5-ui-react)
    * [Async Logic and Data Fetching](https://redux.js.org/tutorials/fundamentals/part-6-async-logic)
    * [Standard Redux Patterns](https://redux.js.org/tutorials/fundamentals/part-7-standard-patterns)
    * [Modern Redux with Redux Toolkit](https://redux.js.org/tutorials/fundamentals/part-8-modern-redux)
* [Recipes](#!)
  * [Recipes: Index](https://redux.js.org/recipes/recipe-index)
  * [Configuring Your Store](https://redux.js.org/recipes/configuring-your-store)
  * [Usage With TypeScript](https://redux.js.org/recipes/usage-with-typescript)
  * [Migrating to Redux](https://redux.js.org/recipes/migrating-to-redux)
  * [Using Object Spread Operator](https://redux.js.org/recipes/using-object-spread-operator)
  * [Reducing Boilerplate](https://redux.js.org/recipes/reducing-boilerplate)
  * [Server Rendering](https://redux.js.org/recipes/server-rendering)
  * [Writing Tests](https://redux.js.org/recipes/writing-tests)
  * [Computing Derived Data](https://redux.js.org/recipes/computing-derived-data)
  * [Implementing Undo History](https://redux.js.org/recipes/implementing-undo-history)
  * [Isolating Redux Sub-Apps](https://redux.js.org/recipes/isolating-redux-sub-apps)
  * [Code Splitting](https://redux.js.org/recipes/code-splitting)
  * [Troubleshooting](https://redux.js.org/recipes/troubleshooting)
  * [Structuring Reducers](#!)
    * [Structuring Reducers](https://redux.js.org/recipes/structuring-reducers/structuring-reducers)
    * [Prerequisite Concepts](https://redux.js.org/recipes/structuring-reducers/prerequisite-concepts)
    * [Basic Reducer Structure](https://redux.js.org/recipes/structuring-reducers/basic-reducer-structure)
    * [Splitting Reducer Logic](https://redux.js.org/recipes/structuring-reducers/splitting-reducer-logic)
    * [Refactoring Reducers Example](https://redux.js.org/recipes/structuring-reducers/refactoring-reducer-example)
    * [Using combineReducers](https://redux.js.org/recipes/structuring-reducers/using-combinereducers)
    * [Beyond combineReducers](https://redux.js.org/recipes/structuring-reducers/beyond-combinereducers)
    * [Normalizing State Shape](https://redux.js.org/recipes/structuring-reducers/normalizing-state-shape)
    * [Updating Normalized Data](https://redux.js.org/recipes/structuring-reducers/updating-normalized-data)
    * [Reusing Reducer Logic](https://redux.js.org/recipes/structuring-reducers/reusing-reducer-logic)
    * [Immutable Update Patterns](https://redux.js.org/recipes/structuring-reducers/immutable-update-patterns)
    * [Initializing State](https://redux.js.org/recipes/structuring-reducers/initializing-state)
* [Understanding Redux](#!)
  * [Thinking in Redux](#!)
    * [Motivation](https://redux.js.org/understanding/thinking-in-redux/motivation)
    * [Three Principles](https://redux.js.org/understanding/thinking-in-redux/three-principles)
    * [Glossary](https://redux.js.org/understanding/thinking-in-redux/glossary)
  * [History and Design](#!)
    * [Prior Art](https://redux.js.org/understanding/history-and-design/prior-art)
    * [Middleware](https://redux.js.org/understanding/history-and-design/middleware)
* [FAQ](#!)
  * [FAQ Index](https://redux.js.org/faq)
  * [General](https://redux.js.org/faq/general)
  * [Reducers](https://redux.js.org/faq/reducers)
  * [Organizing State](https://redux.js.org/faq/organizing-state)
  * [Store Setup](https://redux.js.org/faq/store-setup)
  * [Actions](https://redux.js.org/faq/actions)
  * [Immutable Data](https://redux.js.org/faq/immutable-data)
  * [Code Structure](https://redux.js.org/faq/code-structure)
  * [Performance](https://redux.js.org/faq/performance)
  * [Design Decisions](https://redux.js.org/faq/design-decisions)
  * [React Redux](https://redux.js.org/faq/react-redux)
  * [Miscellaneous](https://redux.js.org/faq/miscellaneous)
* [Style Guide](#!)
  * [Style Guide: Best Practices](https://redux.js.org/style-guide/style-guide)
* [API Reference](#!)
  * [API Reference](https://redux.js.org/api/api-reference)
  * [createStore](https://redux.js.org/api/createstore)
  * [Store](https://redux.js.org/api/store)
  * [combineReducers](https://redux.js.org/api/combinereducers)
  * [applyMiddleware](https://redux.js.org/api/applymiddleware)
  * [bindActionCreators](https://redux.js.org/api/bindactioncreators)
  * [compose](https://redux.js.org/api/compose)
* [Redux Toolkit](#!)
  * [Redux Toolkit: Overview](https://redux.js.org/redux-toolkit/overview)

## `compose(...functions)`[#](#composefunctions)

Composes functions from right to left.

This is a functional programming utility, and is included in Redux as a convenience. You might want to use it to apply several [store enhancers](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer) in a row.

**Arguments**[**#**](#arguments)

1. (*arguments*): The functions to compose. Each function is expected to accept a single parameter. Its return value will be provided as an argument to the function standing to the left, and so on. The exception is the right-most argument which can accept multiple parameters, as it will provide the signature for the resulting composed function.

**Returns**[**#**](#returns)

(*Function*): The final function obtained by composing the given functions from right to left.

**Example**[**#**](#example)

This example demonstrates how to use `compose` to enhance a [store](https://redux.js.org/api/store) with [`applyMiddleware`](https://redux.js.org/api/applymiddleware) and a few developer tools from the [redux-devtools](https://github.com/reduxjs/redux-devtools) package.

import { createStore, applyMiddleware, compose } from 'redux'

import thunk from 'redux-thunk'

import DevTools from './containers/DevTools'

import reducer from '../reducers'

const store = createStore(

reducer,

compose(applyMiddleware(thunk), DevTools.instrument())

)

Copy

**Tips**[**#**](#tips)

* All `compose` does is let you write deeply nested function transformations without the rightward drift of the code. Don't give it too much credit!

Previous

« bindActionCreators

Next

Redux Toolkit: Overview »

**Docs**

* [Getting Started](https://redux.js.org/introduction/getting-started)
* [Tutorial](https://redux.js.org/tutorials/essentials/part-1-overview-concepts)
* [FAQ](https://redux.js.org/faq)
* [API Reference](https://redux.js.org/api/api-reference)

**Community**

* [Reactiflux Discord](https://discord.gg/0ZcbPKXt5bZ6au5t)
* [Stack Overflow](http://stackoverflow.com/questions/tagged/redux)
* [Feedback](https://redux.js.org/introduction/getting-started#help-and-discussion)

**More**

* [GitHub](https://github.com/reduxjs/redux)
* [![Deploys by Netlify](https://www.netlify.com/img/global/badges/netlify-color-accent.svg)](https://www.netlify.com/)

[![Redux Logo](https://d33wubrfki0l68.cloudfront.net/0834d0215db51e91525a25acf97433051f280f2f/c30f5/img/redux.svg)![Redux Logo](https://d33wubrfki0l68.cloudfront.net/0834d0215db51e91525a25acf97433051f280f2f/c30f5/img/redux.svg)](https://redux.js.org/)

Copyright © 2015–2021 Dan Abramov and the Redux documentation authors.


---

# 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://bryan-guner.gitbook.io/my-docs/redux/docs-12/md-docs/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.
