Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 77de675

Browse files
authored
Prep for initial stable release (#30)
* Fix to work correctly with hot module reloading * Remove debug print; fix linter error * Update all example dependencies * Update all babel packages * Fix lodash vulnerability * Update eslint; fix linter errors * Set version to 1.0.0-beta.1 * Fix linter and prettier errors
1 parent 72f761f commit 77de675

File tree

16 files changed

+14379
-9125
lines changed

16 files changed

+14379
-9125
lines changed

README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ produce and consume CSS, it doesn't offer any built-in styles and has no
3737
particular opinion about how the styles end up on your page. The example below
3838
has a simple transition that fades pages in and out.
3939

40-
```js
40+
```jsx
4141
import App, { Container } from 'next/app'
4242
import React from 'react'
4343
import { PageTransition } from 'next-page-transitions'
@@ -58,7 +58,7 @@ export default class MyApp extends App {
5858
return (
5959
<Container>
6060
<PageTransition timeout={300} classNames="page-transition">
61-
<Component {...pageProps} />
61+
<Component {...pageProps} key={router.route} />
6262
</PageTransition>
6363
<style jsx global>{`
6464
.page-transition-enter {
@@ -82,7 +82,7 @@ export default class MyApp extends App {
8282
}
8383
```
8484

85-
When you move to a new page, the `Component` will change, and the
85+
When you move to a new page, the `key` prop will change, and the
8686
`PageTransition` component will detect that. Instead of immediately unmounting
8787
the page, it will apply the `page-transition-exit` class to a wrapper around
8888
the page to initialize the "exit" transition, and will then apply the
@@ -94,18 +94,11 @@ the new page is mounted and a similar pair of `.page-transition-enter` and
9494
`page-transition-enter-active` classes will be applied. This process repeats
9595
every time a new page is navigated to.
9696

97-
### Handling Context/Store changes that update props on the Component
98-
99-
If you happen to have an architecture that allows for changes to flow into
100-
your page from the `_app.js` component, you may notice that transitions trigger
101-
on the page when the props change. To remedy this, provide a key prop on your
102-
Component. With Next.js there is a really great way to do this, using the router.
103-
104-
```js
105-
<PageTransition classNames="page-transition" timeout={300}>
106-
<Component key={this.props.router.route} {...pageProps} />
107-
</PageTransition>
108-
```
97+
**Note**: in previous versions of `next-page-transitions`, it wasn't necessary
98+
to specify the `key` prop on children of `PageTransition`. However, to make hot
99+
module reloading work correctly, it was necessary to make this prop required.
100+
Moving foward, children that don't specify a `key` prop will trigger a warning
101+
in the console. In the future, this may become a runtime error.
109102

110103
### Support for delayed enters
111104

@@ -188,7 +181,7 @@ until showing the network indicator:
188181
}}
189182
loadingClassNames="loading-indicator"
190183
>
191-
<Component {...pageProps} />
184+
<Component {...pageProps} key={router.route} />
192185
</PageTransition>
193186
```
194187

examples/complex-animation/package-lock.json

Lines changed: 2086 additions & 2597 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/complex-animation/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"dev": "next dev"
44
},
55
"dependencies": {
6-
"next": "^6.0.2",
7-
"react": "^16.3.2",
8-
"react-dom": "^16.3.2"
6+
"next": "^8.0.3",
7+
"next-page-transitions": "*",
8+
"react": "^16.8.4",
9+
"react-dom": "^16.8.4"
910
}
1011
}

examples/complex-animation/pages/_app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export default class MyApp extends App {
1414
}
1515

1616
render() {
17-
const { Component, pageProps } = this.props
17+
const { Component, pageProps, router } = this.props
1818
return (
1919
<Container>
2020
<PageTransition timeout={500} classNames="page-transition">
21-
<Component {...pageProps} />
21+
<Component {...pageProps} key={router.route} />
2222
</PageTransition>
2323
<style jsx global>{`
2424
.page-transition-enter {

examples/delayed-enter/package-lock.json

Lines changed: 2179 additions & 2520 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/delayed-enter/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"dev": "next dev"
44
},
55
"dependencies": {
6-
"next": "^6.0.2",
6+
"next": "^8.0.3",
7+
"next-page-transitions": "*",
78
"prop-types": "^15.6.1",
8-
"react": "^16.3.2",
9-
"react-dom": "^16.3.2"
9+
"react": "^16.8.4",
10+
"react-dom": "^16.8.4"
1011
}
1112
}

examples/delayed-enter/pages/_app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class MyApp extends App {
1616
}
1717

1818
render() {
19-
const { Component, pageProps } = this.props
19+
const { Component, pageProps, router } = this.props
2020
return (
2121
<Container>
2222
<PageTransition
@@ -30,7 +30,7 @@ export default class MyApp extends App {
3030
}}
3131
loadingClassNames="loading-indicator"
3232
>
33-
<Component {...pageProps} />
33+
<Component {...pageProps} key={router.route} />
3434
</PageTransition>
3535
<style jsx global>{`
3636
.page-transition-enter {

examples/delayed-enter/pages/about.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class About extends React.Component {
1414

1515
componentDidMount() {
1616
this.timeoutId = setTimeout(() => {
17-
this.props.pageTransitionReadyToEnter()
17+
const { pageTransitionReadyToEnter } = this.props
18+
pageTransitionReadyToEnter()
1819
this.setState({ loaded: true })
1920
}, 2000)
2021
}
@@ -24,7 +25,8 @@ class About extends React.Component {
2425
}
2526

2627
render() {
27-
if (!this.state.loaded) return null
28+
const { loaded } = this.state
29+
if (!loaded) return null
2830
return (
2931
<div className="container-fluid bg-success page">
3032
<h1>About us</h1>

0 commit comments

Comments
 (0)