Last active
September 23, 2017 05:46
-
-
Save waliurjs/0da91e017f5636579921a774be8dc90c to your computer and use it in GitHub Desktop.
Rerendering little bitch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class extends React.Component { | |
constructor(props){ | |
super(props); | |
} | |
componentDidMount(){ | |
console.log('They... mounted me. :( '); | |
} | |
render (){ | |
return ( | |
<div> | |
<style global jsx>{` | |
.noUp { | |
animation-duration: 1s; | |
animation-name: slidein; | |
} | |
@keyframes slidein { | |
from { | |
font-size:30px; | |
} | |
to { | |
font-size:14px; | |
} | |
} | |
`}</style> | |
<div className="noUp">Should not re-render in <b>second</b> and <b>third</b> page</div> | |
</div> | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Rerendering little bitch", | |
"version": "1.0.0", | |
"description": "Next is what", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"next": "^3.2.2", | |
"react": "^15.6.1", | |
"react-dom": "^15.6.1" | |
}, | |
"scripts": { | |
"dev": "next", | |
"build": "next build", | |
"start": "next start" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Link from 'next/link' | |
import Shrink from './../components/shrink'; | |
export default class extends React.Component { | |
constructor(){ | |
super(); | |
this.state = {'localVar': ''}; | |
} | |
render (){ | |
var {localVar} = this.state; | |
return ( | |
<div> | |
<Shrink/> | |
<h4> | |
<Link href="/second" prefetch> | |
<a>Second</a> | |
</Link> | |
<br/> | |
<Link href="/third" prefetch> | |
<a>Third</a> | |
</Link> | |
</h4> | |
<button onClick={ () => { | |
this.setState({'localVar': `${localVar}1` }) | |
}}>Force re-render</button> | |
<span>{localVar}</span> | |
</div> | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Shrink from './../components/shrink'; | |
import Link from 'next/link' | |
export default () => ( | |
<div> | |
<Shrink/> | |
<h4> | |
<Link href="/" prefetch> | |
<a>Back</a> | |
</Link> | |
</h4> | |
</div> | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Link from 'next/link'; | |
import Shrink from './../components/shrink'; | |
export default () => ( | |
<div> | |
<Shrink/> | |
<h4> | |
<Link href="/" prefetch> | |
<a>Back</a> | |
</Link> | |
</h4> | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment