Skip to content

Commit 7839b26

Browse files
committed
Fix error on changing debug property (StacksProvider/useDebugStyle)
1 parent 4a0a717 commit 7839b26

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/context.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { createContext, useContext, useRef } from 'react'
2+
import { ViewStyle } from 'react-native'
23

34
import {
45
Breakpoints,
@@ -65,14 +66,11 @@ export const useBreakpoint = () => {
6566

6667
export const useDebugStyle = () => {
6768
const { debug } = useStacks()
69+
const stylesRef = useRef<ViewStyle>()
6870

69-
if (!debug) {
70-
return undefined
71-
}
71+
stylesRef.current = debug ? { backgroundColor: randomColor() } : undefined
7272

73-
const backgroundColorRef = useRef(randomColor())
74-
75-
return { backgroundColor: backgroundColorRef.current }
73+
return stylesRef.current
7674
}
7775

7876
export const StacksProvider = (props: Props) => {

0 commit comments

Comments
 (0)