Skip to content

Commit 00d8db6

Browse files
⬆️ Bump flow-bin from 0.133.0 to 0.134.0 (#53)
1 parent d04ffa3 commit 00d8db6

File tree

8 files changed

+28
-27
lines changed

8 files changed

+28
-27
lines changed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.*/node_modules/react-native/Libraries/react-native/react-native-implementation.js
33

44
[version]
5-
^0.133.0
5+
^0.134.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"codecov": "^3.1.0",
5959
"eslint": "^7.5.0",
6060
"eslint-plugin-flowtype": "^5.2.0",
61-
"flow-bin": "^0.133.0",
61+
"flow-bin": "^0.134.0",
6262
"jest": "^24.9.0",
6363
"react": "16.6.3",
6464
"react-native": "^0.58.4",

src/ErrorBoundary/FallbackComponent/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow
2-
import React from 'react'
2+
import React, { type Node } from 'react'
33
import {
44
SafeAreaView,
55
Text,
@@ -9,9 +9,9 @@ import {
99

1010
import styles from './styles'
1111

12-
type Props = { error: Error, resetError: Function }
12+
export type Props = { error: Error, resetError: Function }
1313

14-
const FallbackComponent = (props: Props) => (
14+
const FallbackComponent = (props: Props): Node => (
1515
<SafeAreaView style={styles.container}>
1616
<View style={styles.content}>
1717
<Text style={styles.title}>{'Oops!'}</Text>

src/ErrorBoundary/FallbackComponent/styles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22
import { StyleSheet } from 'react-native'
33

4-
export default StyleSheet.create({
4+
const styles: any = StyleSheet.create({
55
container: {
66
backgroundColor: '#fafafa',
77
flex: 1,
@@ -33,3 +33,5 @@ export default StyleSheet.create({
3333
textAlign: 'center'
3434
}
3535
})
36+
37+
export default styles

src/ErrorBoundary/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// @flow
22
import React, { type Node, type ComponentType } from 'react'
33

4-
import FallbackComponent from './FallbackComponent'
4+
import FallbackComponent, { type Props as FallbackComponentProps } from './FallbackComponent'
55

66
type Props = {
77
children: Node,
8-
FallbackComponent: ComponentType<any>,
8+
FallbackComponent: ComponentType<FallbackComponentProps>,
99
onError?: Function
1010
}
1111

12-
type State = { error: Error | null, hasError: boolean }
12+
type State = { error: Error | null }
1313

1414
class ErrorBoundary extends React.Component<Props, State> {
15-
state = { error: null, hasError: false }
15+
state: State = { error: null }
1616

17-
static defaultProps = {
17+
static defaultProps: { FallbackComponent: ComponentType<FallbackComponentProps> } = {
1818
FallbackComponent: FallbackComponent
1919
}
2020

21-
static getDerivedStateFromError (error: Error) {
22-
return { error, hasError: true }
21+
static getDerivedStateFromError (error: Error): State {
22+
return { error }
2323
}
2424

2525
componentDidCatch (error: Error, info: { componentStack: string }) {
@@ -29,13 +29,13 @@ class ErrorBoundary extends React.Component<Props, State> {
2929
}
3030

3131
resetError: Function = () => {
32-
this.setState({ error: null, hasError: false })
32+
this.setState({ error: null })
3333
}
3434

35-
render () {
35+
render (): Node {
3636
const { FallbackComponent } = this.props
3737

38-
return this.state.hasError
38+
return this.state.error
3939
? <FallbackComponent
4040
error={this.state.error}
4141
resetError={this.resetError}

src/__tests__/__snapshots__/errorBoundary.spec.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ exports[`ErrorBoundary should catch errors set the state and render the default
4848
>
4949
Invariant Violation: Objects are not valid as a React child (found: Error: This is a test error!). If you meant to render a collection of children, use an array instead.
5050
in View (created by View)
51-
in View (at errorBoundary.spec.js:41)
52-
in ErrorBoundary (at errorBoundary.spec.js:40)
51+
in View (at errorBoundary.spec.js:40)
52+
in ErrorBoundary (at errorBoundary.spec.js:39)
5353
</Text>
5454
<View
5555
accessible={true}

src/__tests__/errorBoundary.spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ describe('ErrorBoundary', () => {
3131
</ErrorBoundary>
3232
)
3333
expect(wrapper.getInstance().state.error).toBe(null)
34-
expect(wrapper.getInstance().state.hasError).toBe(false)
3534
expect(wrapper).toMatchSnapshot()
3635
})
3736

@@ -41,7 +40,8 @@ describe('ErrorBoundary', () => {
4140
<View>{errorMock}</View>
4241
</ErrorBoundary>
4342
)
44-
expect(wrapper.getInstance().state.hasError).toBe(true)
43+
expect(wrapper.getInstance().state.error).toBeInstanceOf(Error)
44+
expect(wrapper.getInstance().state.error).not.toBeNull()
4545
expect(wrapper).toMatchSnapshot()
4646
})
4747

@@ -53,8 +53,8 @@ describe('ErrorBoundary', () => {
5353
<View>{errorMock}</View>
5454
</ErrorBoundary>
5555
)
56+
expect(wrapper.getInstance().state.error).toBeInstanceOf(Error)
5657
expect(wrapper.getInstance().state.error).not.toBeNull()
57-
expect(wrapper.getInstance().state.hasError).toBe(true)
5858
expect(onError).toHaveBeenCalledWith(expect.any(Error), expect.any(String))
5959
expect(wrapper).toMatchSnapshot()
6060
})
@@ -65,9 +65,8 @@ describe('ErrorBoundary', () => {
6565
<Text>No errors!</Text>
6666
</ErrorBoundary>
6767
)
68-
wrapper.getInstance().setState({ error: errorMock, hasError: true })
68+
wrapper.getInstance().setState({ error: errorMock })
6969
wrapper.getInstance().resetError()
7070
expect(wrapper.getInstance().state.error).toBeNull()
71-
expect(wrapper.getInstance().state.hasError).toBe(false)
7271
})
7372
})

yarn.lock

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

2844-
flow-bin@^0.133.0:
2845-
version "0.133.0"
2846-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.133.0.tgz#2ee44e3f5d0c0256cfe8e99d9a85e9801c281c50"
2847-
integrity sha512-01T5g8GdhtJEn+lhAwuv5zkrMStrmkuHrY3Nn9/aS9y6waNmNgimMKlzRpFH66S0F6Ez9EqU9psz5QaRveSJIA==
2844+
flow-bin@^0.134.0:
2845+
version "0.134.0"
2846+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.134.0.tgz#e98e5724f6ed5a1265cf904bbb5e4c096ea3a026"
2847+
integrity sha512-j5aCugO3jmwDsUKc+7KReArgnL6aVjHLo6DlozKhxKYN+TaP8BY+mintPSISjSQtKZFJyvoNAc1oXA79X5WjIA==
28482848

28492849
for-in@^1.0.1, for-in@^1.0.2:
28502850
version "1.0.2"

0 commit comments

Comments
 (0)