# Upgrade from 5.x to 6.0.0

This version includes changes to the public API, making it easier to import and use the middleware.

## New: Preconfigured by Default

### Before

Previously, the middleware need to be instantiated with an optional configuration.

```javascript
import promiseMiddleware from 'redux-promise-middleware'

applyMiddleware(
  promiseMiddleware({
    // Optional configuration
  }),
)(createStore)
```

This implementation enabled custom configuration, but, for most implementations, it is uncessary overhead.

### After

Now, the default export is preconfigured and ready to go.

```javascript
import promise from 'redux-promise-middleware'

applyMiddleware(
  promise,
)(createStore)
```

The middleware still supports custom configuration: import `createPromise` and pass in the configuration object.

```javascript
import { createPromise } from 'redux-promise-middleware'

applyMiddleware(
  createPromise({
    // Custom configuration
    typeDelimiter: '/',
  }),
)(createStore)
```

## New: `ActionType` Export

### Before

```javascript
import { PENDING, FULFILLED, REJECTED } from 'redux-promise-middleware'
```

Previously, the middleware exported three string constants. One each for the pending, fulfilled and rejected action types. This is useful for reducers, for example:

```javascript
const reducer = (state = {}, action) => {
  switch(action.type) {
    case `FOO_${PENDING}`:
      // ..

    case `FOO_${FULFILLED}`:
      // ...

    default: return state;
  }
}
```

This is a nice affordance, it could be better design if the action types were exported as an enum (E.g., an object, since this is just JavaScript), as opposed three individual strings.

### After

```javascript
import { ActionType } from 'redux-promise-middleware'
```

Now, the action types are exported as one enum.

```javascript
const reducer = (state = {}, action) => {
  switch(action.type) {
    case `FOO_${ActionType.Pending}`:
      // ..

    case `FOO_${ActionType.Fulfilled}`:
      // ...

    case `FOO_${ActionType.Rejected}`:
      // ...

    default: return state;
  }
}
```

Using action types is entirely optional. One one hand, code benefits from more robust types and is less prone to static errors, but, on another hand, you and your team spends more time and effort writing the code.

At the end of the day, you can also just use regular strings like any other action.

```javascript
const reducer = (state = {}, action) => {
  switch(action.type) {
    case `FOO_PENDING`:
      // ..

    case `FOO_FULFILLED`:
      // ...

    case `FOO_REJECTED`:
      // ...

    default: return state;
  }
}
```


---

# 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://pburtchaell.gitbook.io/redux-promise-middleware/upgrade-guides/v6.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.
