mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Remove UNSAFE_ lifecycles from tests (#5031)
* Remove UNSAFE_componentWillMount * Remove UNSAFE_componentWillReceiveProps from lifecycle
This commit is contained in:
parent
9532cc1256
commit
dfafad488a
|
@ -11,13 +11,15 @@ export default class UrlPropChange extends React.Component {
|
|||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
UNSAFE_componentWillReceiveProps (nextProps) {
|
||||
this.setState(() => {
|
||||
return {
|
||||
previousUrl: this.props.url,
|
||||
url: nextProps.url
|
||||
}
|
||||
})
|
||||
componentDidUpdate (prevProps) {
|
||||
if (prevProps.url !== this.props.url) {
|
||||
this.setState(() => {
|
||||
return {
|
||||
previousUrl: prevProps.url,
|
||||
url: this.props.url
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
import React, { Component } from 'react'
|
||||
|
||||
export default class Statefull extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
|
||||
this.state = { answer: null }
|
||||
}
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
UNSAFE_componentWillMount () {
|
||||
this.setState({ answer: 42 })
|
||||
}
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<p id='answer'>The answer is {this.state.answer}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ describe('Basic Features', () => {
|
|||
renderViaHTTP(context.appPort, '/head'),
|
||||
renderViaHTTP(context.appPort, '/json'),
|
||||
renderViaHTTP(context.appPort, '/link'),
|
||||
renderViaHTTP(context.appPort, '/stateful'),
|
||||
renderViaHTTP(context.appPort, '/stateless'),
|
||||
renderViaHTTP(context.appPort, '/fragment-syntax'),
|
||||
renderViaHTTP(context.appPort, '/custom-extension'),
|
||||
|
|
|
@ -20,12 +20,6 @@ export default function ({ app }, suiteName, render, fetch) {
|
|||
expect(html.includes('My component!')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('renders a stateful component', async () => {
|
||||
const $ = await get$('/stateful')
|
||||
const answer = $('#answer')
|
||||
expect(answer.text()).toBe('The answer is 42')
|
||||
})
|
||||
|
||||
// default-head contains an empty <Head />.
|
||||
test('header renders default charset', async () => {
|
||||
const html = await (render('/default-head'))
|
||||
|
|
Loading…
Reference in a new issue