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
// require your modules | |
var express = require('express') | |
var bodyParser = require('body-parser') | |
// create instance of express | |
var app = express() | |
// let app use body-parser | |
// this one is parsing application/x-www-form-urlencoded | |
app.use(bodyParser.urlencoded({ extended: false })) |
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
function flookThis (input) { | |
console.log(input) | |
} |
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
// example | |
// don't overthink this too much | |
class X extends PureComponent { | |
// constructor equivalent for creating initial state | |
state = { | |
something: '' | |
} | |
// function that returns another function | |
changeReturn = () => e => { |
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
.icon::before { | |
animation: cc 5s infinite linear; | |
} | |
@keyframes cc { | |
0% { | |
color: #fff; | |
} | |
10% { |
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
class E extends PureComponent { | |
changeText = e => { | |
this.setState({ | |
text: e.target.value | |
}); | |
} | |
render() { | |
return ( | |
<div onClick={this.changeText} /> |
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
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] |
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
class FirstComponent extends Component { | |
state = { | |
a: 2 | |
} | |
changeState = val => { | |
this.setState({ | |
a: val | |
}) | |
} |
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
// smart boi with redux would do it like this | |
store = { | |
notification: { | |
status: 'error', | |
message: 'Error message' | |
} || { | |
status: 'success', | |
message: 'Success message' | |
} | |
} |
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 ({ error, success }) => { | |
const message = error.message ? error.message : success.message | |
return ( | |
<div> | |
{message} | |
</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
// That first component lul | |
... | |
render() { | |
return ( | |
... | |
<Notification error={this.state.error} success={this.state.success} /> | |
... | |
) | |
} |