Skip to content

Commit cf00fbd

Browse files
fix(deps): update dependency @growthbook/growthbook-react to v0.22.0 (#1789)
* fix(deps): update dependency @growthbook/growthbook-react to v0.22.0 * chore: add changeset renovate-446b7ad --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Scaleway Bot <github@scaleway.com>
1 parent 5bfa518 commit cf00fbd

File tree

9 files changed

+34
-32
lines changed

9 files changed

+34
-32
lines changed

.changeset/renovate-446b7ad.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@scaleway/use-growthbook': patch
3+
---
4+
5+
Updated dependency `@growthbook/growthbook-react` to `0.24.0`.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"type": "module",
88
"packageManager": "pnpm@8.15.4",
99
"engines": {
10-
"node": ">=18.x",
11-
"pnpm": ">=7.x"
10+
"node": ">=20.x",
11+
"pnpm": ">=8.x"
1212
},
1313
"devDependencies": {
1414
"@babel/core": "7.24.0",

packages/use-growthbook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"feature flags"
2626
],
2727
"dependencies": {
28-
"@growthbook/growthbook-react": "0.21.0"
28+
"@growthbook/growthbook-react": "0.24.0"
2929
},
3030
"devDependencies": {
3131
"react": "18.2.0"

packages/use-growthbook/src/AbTestProvider.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ export const AbTestProvider = ({
7272
useEffect(() => {
7373
const currentAttributes = growthbook.getAttributes()
7474
if (currentAttributes !== attributes) {
75-
growthbook.setAttributes({
76-
...currentAttributes,
77-
...attributes,
78-
})
75+
growthbook
76+
.setAttributes({
77+
...currentAttributes,
78+
...attributes,
79+
})
80+
.catch(errorCallback)
7981
}
80-
}, [attributes, growthbook])
82+
}, [attributes, growthbook, errorCallback])
8183

8284
return (
8385
<GrowthBookProvider growthbook={growthbook}>{children}</GrowthBookProvider>

packages/use-growthbook/src/__mocks__/@growthbook/growthbook-react.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { GrowthBook as GBType } from '@growthbook/growthbook-react'
12
import { jest } from '@jest/globals'
23
import type { ReactNode } from 'react'
34

45
const GrowthBook = jest.fn(() => ({
5-
loadFeatures: jest.fn(),
6-
getAttributes: jest.fn(),
7-
setAttributes: jest.fn(),
6+
loadFeatures: jest.fn<GBType['loadFeatures']>(),
7+
getAttributes: jest.fn<GBType['getAttributes']>(),
8+
setAttributes: jest.fn<GBType['setAttributes']>(() => Promise.resolve()),
89
}))
910
const GrowthBookProvider = ({ children }: { children: ReactNode }) => children
1011

packages/use-growthbook/src/__tests__/AbTestProvider.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ type TrackingCallback = ComponentProps<
1111
type ErrorCallback = ComponentProps<typeof AbTestProvider>['errorCallback']
1212

1313
describe('AbTestProvider', () => {
14-
let trackingCallback: TrackingCallback
15-
let errorCallback: ErrorCallback
14+
const trackingCallback = jest.fn<TrackingCallback>()
15+
const errorCallback: ErrorCallback = () => null
1616

1717
beforeEach(() => {
18-
trackingCallback = jest.fn()
1918
jest.clearAllMocks()
2019
})
2120
it('should init GrowthBook once', () => {

packages/use-growthbook/src/__tests__/useAbTestAttributes.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ jest.mock('@growthbook/growthbook-react')
88

99
describe('useAbTestAttributes', () => {
1010
let getAttributes: () => Attributes
11-
let setAttributes: (attributes: Attributes) => null | undefined
11+
let setAttributes: (attributes: Attributes) => Promise<void>
1212

1313
beforeEach(() => {
14-
getAttributes = jest
15-
.fn()
16-
.mockReturnValue({ foo: 'bar' }) as () => Attributes
17-
setAttributes = jest.fn() as (attributes: Attributes) => null | undefined
14+
getAttributes = jest.fn<() => Attributes>().mockReturnValue({ foo: 'bar' })
15+
setAttributes = jest.fn(() => Promise.resolve())
16+
1817
jest.spyOn(growthbook, 'useGrowthBook').mockReturnValue({
1918
getAttributes,
2019
setAttributes,

packages/use-growthbook/src/types.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Context } from '@growthbook/growthbook-react'
1+
import type { Context, GrowthBook } from '@growthbook/growthbook-react'
22

33
export type Attributes = Record<string, string | number | undefined>
44

@@ -7,11 +7,7 @@ export type Attributes = Record<string, string | number | undefined>
77
* @param {number} [timeout] - 500.
88
* @param {boolean} [skipCache] - false.
99
*/
10-
export type LoadConfig = {
11-
autoRefresh: boolean
12-
timeout: number
13-
skipCache: boolean
14-
}
10+
export type LoadConfig = NonNullable<Parameters<GrowthBook['loadFeatures']>[0]>
1511

1612
export type ToolConfig = Pick<
1713
Context,

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)