Skip to content

Commit 306befa

Browse files
committed
Match propTypes to TS-types
1 parent ca118fe commit 306befa

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

packages/react-async/src/helpers.spec.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import "@testing-library/jest-dom/extend-expect"
22
import React from "react"
33
import { render, fireEvent, cleanup } from "@testing-library/react"
44
import Async, { IfInitial, IfPending, IfFulfilled, IfRejected, IfSettled } from "./index"
5-
import { resolveIn, resolveTo, rejectTo } from "./specs"
5+
import { resolveIn, resolveTo, rejectTo, sleep } from "./specs"
66

77
afterEach(cleanup)
88

@@ -84,6 +84,12 @@ describe("IfFulfilled", () => {
8484
await findByText("outer inner")
8585
expect(queryByText("outer inner")).toBeInTheDocument()
8686
})
87+
88+
test("renders without children", async () => {
89+
const promiseFn = () => resolveTo("ok")
90+
render(<Async promiseFn={promiseFn}>{state => <IfFulfilled state={state} />}</Async>)
91+
await sleep(0)
92+
})
8793
})
8894

8995
describe("IfPending", () => {

packages/react-async/src/helpers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const renderFn = (children: React.ReactNode | ChildrenFn, ...args: any[]) => {
3333
const render = children as ChildrenFn
3434
return render(...args)
3535
}
36-
return children === undefined ? null : children
36+
return children
3737
}
3838

3939
/**

packages/react-async/src/propTypes.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@ export default PropTypes && {
4646
debugLabel: PropTypes.string,
4747
},
4848
Initial: {
49-
children: childrenFn.isRequired,
49+
children: childrenFn,
5050
state: stateObject.isRequired,
5151
persist: PropTypes.bool,
5252
},
5353
Pending: {
54-
children: childrenFn.isRequired,
54+
children: childrenFn,
5555
state: stateObject.isRequired,
5656
initial: PropTypes.bool,
5757
},
5858
Fulfilled: {
59-
children: childrenFn.isRequired,
59+
children: childrenFn,
6060
state: stateObject.isRequired,
6161
persist: PropTypes.bool,
6262
},
6363
Rejected: {
64-
children: childrenFn.isRequired,
64+
children: childrenFn,
6565
state: stateObject.isRequired,
6666
persist: PropTypes.bool,
6767
},
6868
Settled: {
69-
children: childrenFn.isRequired,
69+
children: childrenFn,
7070
state: stateObject.isRequired,
7171
persist: PropTypes.bool,
7272
},

0 commit comments

Comments
 (0)