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

Commit

Permalink
Prep for initial stable release (#30)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nwalters512 authored Mar 14, 2019
1 parent 72f761f commit 77de675
Show file tree
Hide file tree
Showing 16 changed files with 14,379 additions and 9,125 deletions.
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ produce and consume CSS, it doesn't offer any built-in styles and has no
particular opinion about how the styles end up on your page. The example below
has a simple transition that fades pages in and out.

```js
```jsx
import App, { Container } from 'next/app'
import React from 'react'
import { PageTransition } from 'next-page-transitions'
Expand All @@ -58,7 +58,7 @@ export default class MyApp extends App {
return (
<Container>
<PageTransition timeout={300} classNames="page-transition">
<Component {...pageProps} />
<Component {...pageProps} key={router.route} />
</PageTransition>
<style jsx global>{`
.page-transition-enter {
Expand All @@ -82,7 +82,7 @@ export default class MyApp extends App {
}
```

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

### Handling Context/Store changes that update props on the Component

If you happen to have an architecture that allows for changes to flow into
your page from the `_app.js` component, you may notice that transitions trigger
on the page when the props change. To remedy this, provide a key prop on your
Component. With Next.js there is a really great way to do this, using the router.

```js
<PageTransition classNames="page-transition" timeout={300}>
<Component key={this.props.router.route} {...pageProps} />
</PageTransition>
```
**Note**: in previous versions of `next-page-transitions`, it wasn't necessary
to specify the `key` prop on children of `PageTransition`. However, to make hot
module reloading work correctly, it was necessary to make this prop required.
Moving foward, children that don't specify a `key` prop will trigger a warning
in the console. In the future, this may become a runtime error.

### Support for delayed enters

Expand Down Expand Up @@ -188,7 +181,7 @@ until showing the network indicator:
}}
loadingClassNames="loading-indicator"
>
<Component {...pageProps} />
<Component {...pageProps} key={router.route} />
</PageTransition>
```

Expand Down
4,683 changes: 2,086 additions & 2,597 deletions examples/complex-animation/package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions examples/complex-animation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"dev": "next dev"
},
"dependencies": {
"next": "^6.0.2",
"react": "^16.3.2",
"react-dom": "^16.3.2"
"next": "^8.0.3",
"next-page-transitions": "*",
"react": "^16.8.4",
"react-dom": "^16.8.4"
}
}
4 changes: 2 additions & 2 deletions examples/complex-animation/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default class MyApp extends App {
}

render() {
const { Component, pageProps } = this.props
const { Component, pageProps, router } = this.props
return (
<Container>
<PageTransition timeout={500} classNames="page-transition">
<Component {...pageProps} />
<Component {...pageProps} key={router.route} />
</PageTransition>
<style jsx global>{`
.page-transition-enter {
Expand Down
4,699 changes: 2,179 additions & 2,520 deletions examples/delayed-enter/package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions examples/delayed-enter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"dev": "next dev"
},
"dependencies": {
"next": "^6.0.2",
"next": "^8.0.3",
"next-page-transitions": "*",
"prop-types": "^15.6.1",
"react": "^16.3.2",
"react-dom": "^16.3.2"
"react": "^16.8.4",
"react-dom": "^16.8.4"
}
}
4 changes: 2 additions & 2 deletions examples/delayed-enter/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class MyApp extends App {
}

render() {
const { Component, pageProps } = this.props
const { Component, pageProps, router } = this.props
return (
<Container>
<PageTransition
Expand All @@ -30,7 +30,7 @@ export default class MyApp extends App {
}}
loadingClassNames="loading-indicator"
>
<Component {...pageProps} />
<Component {...pageProps} key={router.route} />
</PageTransition>
<style jsx global>{`
.page-transition-enter {
Expand Down
6 changes: 4 additions & 2 deletions examples/delayed-enter/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class About extends React.Component {

componentDidMount() {
this.timeoutId = setTimeout(() => {
this.props.pageTransitionReadyToEnter()
const { pageTransitionReadyToEnter } = this.props
pageTransitionReadyToEnter()
this.setState({ loaded: true })
}, 2000)
}
Expand All @@ -24,7 +25,8 @@ class About extends React.Component {
}

render() {
if (!this.state.loaded) return null
const { loaded } = this.state
if (!loaded) return null
return (
<div className="container-fluid bg-success page">
<h1>About us</h1>
Expand Down
Loading

0 comments on commit 77de675

Please sign in to comment.