Skip to content

Commit

Permalink
Update redux integration docs for newer Redux configureStore API (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Dec 28, 2023
1 parent 8bd148e commit 99a795d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<PlatformContent includePath="configuration/redux-init" />

If you have other enhancers or middleware such as `thunk`:
If you are using the deprecated `createStore` API and have other enhancers or middleware such as `thunk`:

```javascript
const store = createStore(
Expand Down
13 changes: 10 additions & 3 deletions src/platform-includes/configuration/redux-init/javascript.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```javascript
import { createStore, compose } from "redux";
import { configureStore, createStore, compose } from "redux";
import * as Sentry from "@sentry/react";

// ...
Expand All @@ -8,7 +8,14 @@ const sentryReduxEnhancer = Sentry.createReduxEnhancer({
// Optionally pass options listed below
});

const store = createStore(rootReducer, sentryReduxEnhancer);
// If you are using the `configureStore` API, pass the enhancer as follows:
const store = configureStore({
reducer,
enhancers: (getDefaultEnhancers) => {
return getDefaultEnhancers().concat(sentryReduxEnhancer);
},
});

// ...
// If you are using the deprecated `createStore` API, pass the enhancer as follows:
const store = createStore(reducer, sentryReduxEnhancer);
```
13 changes: 10 additions & 3 deletions src/platform-includes/configuration/redux-init/react-native.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```javascript
import { createStore, compose } from "redux";
import { configureStore, createStore, compose } from "redux";
import * as Sentry from "@sentry/react-native";

// ...
Expand All @@ -8,7 +8,14 @@ const sentryReduxEnhancer = Sentry.createReduxEnhancer({
// Optionally pass options listed below
});

const store = createStore(rootReducer, sentryReduxEnhancer);
// If you are using the `configureStore` API, pass the enhancer as follows:
const store = configureStore({
reducer,
enhancers: (getDefaultEnhancers) => {
return getDefaultEnhancers().concat(sentryReduxEnhancer);
},
});

// ...
// If you are using the deprecated `createStore` API, pass the enhancer as follows:
const store = createStore(reducer, sentryReduxEnhancer);
```
4 changes: 1 addition & 3 deletions src/platforms/javascript/guides/react/features/redux.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ redirect_from:
- /platforms/javascript/guides/react/configuration/integrations/redux/
---

_(Available in version 5.20.0 and above)_

Redux support is included in the `@sentry/react` package since version `5.20.0`. To apply Sentry to Redux, use `Sentry.createReduxEnhancer` at the same place that you initialize your Redux store.
To capture Redux state data, use `Sentry.createReduxEnhancer` in the same place that you initialize your Redux store.

<Include name="platforms/configuration/integrations/redux.mdx" />

Expand Down

1 comment on commit 99a795d

@vercel
Copy link

@vercel vercel bot commented on 99a795d Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs-git-master.sentry.dev
docs.sentry.io
sentry-docs.sentry.dev

Please sign in to comment.