Skip to content

Commit 5b3cf49

Browse files
authored
replace createRef with useRef (#3124)
* replace createRef with useRef * changeset * missed null
1 parent 7eaad16 commit 5b3cf49

File tree

9 files changed

+63
-163
lines changed

9 files changed

+63
-163
lines changed

.changeset/bright-stingrays-accept.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
replace createRef with useRef

docs/content/ActionMenu.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ To create an anchor outside of the menu, you need to switch to controlled mode f
222222
```javascript live noinline
223223
const Example = () => {
224224
const [open, setOpen] = React.useState(false)
225-
const anchorRef = React.createRef()
225+
const anchorRef = React.useRef(null)
226226

227227
return (
228228
<>

docs/package-lock.json

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

examples/nextjs/package-lock.json

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

src/ActionMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>> = ({
102102
'anchorRef'
103103
>
104104

105-
const containerRef = React.createRef<HTMLDivElement>()
105+
const containerRef = React.useRef<HTMLDivElement>(null)
106106
useMenuKeyboardNavigation(open, onClose, containerRef, anchorRef)
107107

108108
return (

src/ActionMenu/ActionMenu.examples.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const ControlledMenu = () => {
111111
const onSelect = (name: string) => fireAction(name)
112112

113113
const [open, setOpen] = React.useState(false)
114-
const triggerRef = React.createRef<HTMLButtonElement>()
114+
const triggerRef = React.useRef<HTMLButtonElement>(null)
115115

116116
return (
117117
<>

src/ActionMenu/ActionMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const Overlay: React.FC<React.PropsWithChildren<MenuOverlayProps>> = ({children,
9797
'anchorRef'
9898
>
9999

100-
const containerRef = React.createRef<HTMLDivElement>()
100+
const containerRef = React.useRef<HTMLDivElement>(null)
101101
useMenuKeyboardNavigation(open, onClose, containerRef, anchorRef)
102102

103103
return (

src/__tests__/hooks/useMenuInitialFocus.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const Component = () => {
66
const [open, setOpen] = React.useState(false)
77
const onOpen = () => setOpen(!open)
88

9-
const containerRef = React.createRef<HTMLDivElement>()
10-
const anchorRef = React.createRef<HTMLButtonElement>()
9+
const containerRef = React.useRef<HTMLDivElement>(null)
10+
const anchorRef = React.useRef<HTMLButtonElement>(null)
1111
useMenuInitialFocus(open, containerRef, anchorRef)
1212

1313
return (

src/__tests__/hooks/useMnemonics.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Fixture = ({
1313
hasTextarea?: boolean
1414
refNotAttached?: boolean
1515
}) => {
16-
const containerRef = React.createRef<HTMLDivElement>()
16+
const containerRef = React.useRef<HTMLDivElement>(null)
1717
useMnemonics(true, containerRef) // hard coding open=true for test
1818

1919
return (

0 commit comments

Comments
 (0)