Skip to content

Commit a0333cc

Browse files
author
Lasse Borly
committed
add transition TS types and prop-types, reflect changes in readme, update snapshot
1 parent f0154d5 commit a0333cc

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

.size-snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"dist/addons.umd.js": {
3-
"bundled": 16003,
3+
"bundled": 16024,
44
"minified": 5898,
55
"gzipped": 2150
66
},
77
"dist/web.umd.js": {
8-
"bundled": 86075,
8+
"bundled": 86161,
99
"minified": 35541,
1010
"gzipped": 12021
1111
}

index.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,15 @@ interface TransitionProps<S extends object, DS extends object = {}> {
162162
*/
163163
items?: Array<TransitionItemProps> | TransitionItemProps
164164

165-
children?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
166-
167-
render?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
165+
children?:
166+
| SpringRendererFunc<S, DS>
167+
| Array<SpringRendererFunc<S, DS>>
168+
| boolean
169+
170+
render?:
171+
| SpringRendererFunc<S, DS>
172+
| Array<SpringRendererFunc<S, DS>>
173+
| boolean
168174
}
169175

170176
export class Transition<

readme.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { Spring, ... } from 'react-spring/dist/universal'
1515

1616
# Table of Contents 👇
1717

18-
* [What is it?](#what-is-it-)
19-
* [Why do we need yet another?](#why-do-we-need-yet-another-)
20-
* [Links](#links-)
21-
* [Basic overview](#basic-overview-)
22-
* [Interpolation](#interpolation-)
23-
* [Render props](#render-props-)
24-
* [Native rendering](#native-rendering-)
25-
* [React-native and other targets](#react-native-and-other-targets-)
18+
- [What is it?](#what-is-it-)
19+
- [Why do we need yet another?](#why-do-we-need-yet-another-)
20+
- [Links](#links-)
21+
- [Basic overview](#basic-overview-)
22+
- [Interpolation](#interpolation-)
23+
- [Render props](#render-props-)
24+
- [Native rendering](#native-rendering-)
25+
- [React-native and other targets](#react-native-and-other-targets-)
2626

2727
# What is it? 🤔
2828

@@ -68,7 +68,6 @@ react-spring builds upon animated's foundation, making it leaner and more flexib
6868

6969
For a more detailed explanation read [Why React needed yet another animation library](https://medium.com/@drcmda/why-react-needed-yet-another-animation-library-introducing-react-spring-8212e424c5ce).
7070

71-
7271
# Links 🔗
7372

7473
#### [Examples and Codesandboxes](https://github.com/drcmda/react-spring/blob/master/examples)
@@ -127,11 +126,22 @@ Given a single child instead of a list you can toggle between two components.
127126
import { Transition } from 'react-spring'
128127

129128
<Transition from={{ opacity: 0 }} enter={{ opacity: 1 }} leave={{ opacity: 0 }}>
130-
{toggle ? ComponentA : ComponentB}
129+
{toggle
130+
? styles => <ComponentA style={styles} />
131+
: styles => <ComponentB style={styles} />
132+
}
131133
</Transition>
132134
```
133135

134-
If you need to toggle a single child, that is also possible: `{toggle && Component}`
136+
If you need to toggle a single child, that is also possible.
137+
138+
```jsx
139+
import { Transition } from 'react-spring'
140+
141+
<Transition from={{ opacity: 0 }} enter={{ opacity: 1 }} leave={{ opacity: 0 }}>
142+
{visible && (styles => <SingleComponent style={styles} />)}
143+
</Transition>
144+
```
135145

136146
#### Trails and staggered animations ([Demo](https://codesandbox.io/embed/vvmv6x01l5))
137147

@@ -279,7 +289,6 @@ const AnimatedView = animated(View)
279289
This project exists thanks to all the people who contribute. [[Contribute]](CONTRIBUTING.md).
280290
<a href="graphs/contributors"><img src="https://opencollective.com/react-spring/contributors.svg?width=890" /></a>
281291

282-
283292
# Backers
284293

285294
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/react-spring#backer)]

src/Transition.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ export default class Transition extends React.PureComponent {
5252
children: PropTypes.oneOfType([
5353
PropTypes.arrayOf(PropTypes.func),
5454
PropTypes.func,
55+
PropTypes.bool,
5556
]),
5657
render: PropTypes.oneOfType([
5758
PropTypes.arrayOf(PropTypes.func),
5859
PropTypes.func,
60+
PropTypes.bool,
5961
]),
6062
}
6163

0 commit comments

Comments
 (0)