Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit a5ce0a2

Browse files
Upgrade flow (#397)
1 parent 1b5ad3e commit a5ce0a2

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[lints]
1010

1111
[options]
12-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectError
12+
types_first=false
1313

1414
[strict]
1515

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"eslint-plugin-promise": "^4.2.1",
9494
"eslint-plugin-react": "^7.19.0",
9595
"eslint-plugin-react-hooks": "^3.0.0",
96-
"flow-bin": "^0.122.0",
96+
"flow-bin": "^0.139.0",
9797
"flow-copy-source": "^2.0.9",
9898
"gh-pages": "^2.2.0",
9999
"git-branch-is": "^3.1.0",

src/Popper.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React from 'react';
33
import { render, waitFor, act } from '@testing-library/react';
44
import * as PopperJs from '@popperjs/core';
5+
import type { Ref } from './RefTypes';
56

67
// Public API
78
import { Popper } from '.';
@@ -22,6 +23,14 @@ const renderPopper = async (props): any => {
2223
return result;
2324
};
2425

26+
const handleRef = (ref: Ref) => (node: ?HTMLElement) => {
27+
if (typeof ref === 'function') {
28+
ref(node);
29+
} else if (typeof ref === 'function') {
30+
ref.current = node;
31+
}
32+
};
33+
2534
describe('Popper component', () => {
2635
it('renders the expected markup', async () => {
2736
const referenceElement = document.createElement('div');
@@ -41,11 +50,11 @@ describe('Popper component', () => {
4150
<Popper referenceElement={referenceElement}>
4251
{({ ref, style, placement, arrowProps }) => (
4352
<div
44-
ref={(current) => ref(current)}
53+
ref={handleRef(ref)}
4554
style={style}
4655
data-placement={placement}
4756
>
48-
<div {...arrowProps} ref={(current) => arrowProps.ref(current)} />
57+
<div {...arrowProps} ref={handleRef(arrowProps.ref)} />
4958
</div>
5059
)}
5160
</Popper>

src/RefTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
// @flow
12
type RefHandler = (?HTMLElement) => void;
2-
type RefObject = { current?: HTMLElement};
3+
type RefObject = { current?: ?HTMLElement};
34

45
export type Ref = RefHandler | RefObject;

src/__typings__/main-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Manager, Reference, Popper } from '..';
88

99
export const Test = () => (
1010
<Manager>
11-
{/* $FlowExpectError: empty children */}
11+
{/* $FlowExpectedError: empty children */}
1212
<Reference />
1313
<Reference>{({ ref }) => <div ref={ref} />}</Reference>
1414
<Popper

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,10 +3648,10 @@ flatted@^2.0.0:
36483648
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
36493649
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
36503650

3651-
flow-bin@^0.122.0:
3652-
version "0.122.0"
3653-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.122.0.tgz#c723a2b33b1a70bd10204704ae1dc776d5d89d79"
3654-
integrity sha512-my8N5jgl/A+UVby9E7NDppHdhLgRbWgKbmFZSx2MSYMRh3d9YGnM2MM+wexpUpl0ftY1IM6ZcUwaAhrypLyvlA==
3651+
flow-bin@^0.139.0:
3652+
version "0.139.0"
3653+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.139.0.tgz#3ad6c75460be45b64f00521035c5affb3c440df5"
3654+
integrity sha512-eilVetLwztYtKjRj//4OsJ7aw47hsUZ8GTINxaZHWhpqiFikErQL0sV/3hQtpm54w9FuS2PO4yvbU0pWrtckqg==
36553655

36563656
flow-copy-source@^2.0.9:
36573657
version "2.0.9"

0 commit comments

Comments
 (0)