Skip to content

Commit

Permalink
Prepare for Next deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyis committed Apr 19, 2018
1 parent 0d5e15f commit 045bd2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions pages/plugins.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import Router from 'next/router'
import { withRouter } from 'next/router'
import Head from 'next/head'
import Layout from '../components/Layout'
import PluginsList from '../components/PluginsList'
import Filter from '../components/Filter'
import getPlugins from '../lib/get-plugins'

export default class extends React.Component {
class Plugins extends React.Component {
constructor() {
super()

Expand All @@ -32,7 +32,7 @@ export default class extends React.Component {
}

componentDidUpdate(prevProps) {
if (prevProps.url.asPath !== this.props.url.asPath) {
if (prevProps.router.asPath !== this.props.router.asPath) {
const newFilter = this.readFilterFromURL()
this.handleFilterChange(newFilter)
}
Expand All @@ -49,12 +49,12 @@ export default class extends React.Component {
}

readFilterFromURL() {
return this.props.url.asPath.split('?')[1]
return this.props.router.asPath.split('?')[1]
}

updateFilterURL(newFilter) {
const href = `/plugins?${newFilter}`
Router.push(href, href, { shallow: true })
this.props.router.push(href, href, { shallow: true })
}

render() {
Expand All @@ -73,3 +73,5 @@ export default class extends React.Component {
)
}
}

export default withRouter(Plugins)
12 changes: 7 additions & 5 deletions pages/themes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import Router from 'next/router'
import { withRouter } from 'next/router'
import Head from 'next/head'
import Layout from '../components/Layout'
import PluginsList from '../components/PluginsList'
import Filter from '../components/Filter.js'
import getPlugins from '../lib/get-plugins'

export default class extends React.Component {
class Themes extends React.Component {
constructor() {
super()

Expand All @@ -32,7 +32,7 @@ export default class extends React.Component {
}

componentDidUpdate(prevProps) {
if (prevProps.url.asPath !== this.props.url.asPath) {
if (prevProps.router.asPath !== this.props.router.asPath) {
const newFilter = this.readFilterFromURL()
this.handleFilterChange(newFilter)
}
Expand All @@ -49,12 +49,12 @@ export default class extends React.Component {
}

readFilterFromURL() {
return this.props.url.asPath.split('?')[1]
return this.props.router.asPath.split('?')[1]
}

updateFilterURL(newFilter) {
const href = `/themes?${newFilter}`
Router.push(href, href, { shallow: true })
this.props.router.push(href, href, { shallow: true })
}

render() {
Expand All @@ -73,3 +73,5 @@ export default class extends React.Component {
)
}
}

export default withRouter(Themes)

0 comments on commit 045bd2c

Please sign in to comment.