Skip to content

Commit 8bb5c90

Browse files
committed
use Nullable.forEach
1 parent 6d659e5 commit 8bb5c90

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pages/docs/react/latest/forwarding-refs.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ let make = () => {
108108
let input = React.useRef(Nullable.null)
109109
110110
let focusInput = () =>
111-
input.current->Nullable.toOption->Option.forEach(input => input->focus)
111+
input.current->Nullable.forEach(input => input->focus)
112112
113113
let onClick = _ => focusInput()
114114

src/Playground.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ module WarningFlagsWidget = {
542542
// Used for the text input
543543
let inputRef = React.useRef(Nullable.null)
544544

545-
let focusInput = () => inputRef.current->Nullable.toOption->Option.forEach(el => el->focus)
545+
let focusInput = () => inputRef.current->Nullable.forEach(el => el->focus)
546546

547-
let blurInput = () => inputRef.current->Nullable.toOption->Option.forEach(el => el->blur)
547+
let blurInput = () => inputRef.current->Nullable.forEach(el => el->blur)
548548

549549
let chips = Array.mapWithIndex(flags, (token, i) => {
550550
let {WarningFlagDescription.Parser.flag: flag, enabled} = token

src/components/SearchBox.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let make = (
2525
onClear()
2626
}
2727

28-
let focusInput = () => textInput.current->Nullable.toOption->Option.forEach(el => el->focus)
28+
let focusInput = () => textInput.current->Nullable.forEach(el => el->focus)
2929

3030
let onAreaFocus = evt => {
3131
let el = ReactEvent.Focus.target(evt)

0 commit comments

Comments
 (0)