Skip to content

Instantly share code, notes, and snippets.

View squalvj's full-sized avatar
24/7

Aditya Wiraha squalvj

24/7
View GitHub Profile
@squalvj
squalvj / webpack.config.js
Created September 15, 2018 13:15
Webpack config for SASS + Babel
const path = require('path');
module.exports = {
entry: './assets/js/dev/index.js',
output: {
filename: 'bundle.js',
// __dirname is a function that npm itself have in the library
path: path.resolve(__dirname, './assets/js/dist')
},
module: {
@squalvj
squalvj / React, SetState Callback
Created September 14, 2018 15:39
React, SetState Callback
_onClickHandler: function _onClickHandler() {
console.log('State before (_onClickHandler): ' + JSON.stringify(this.state));
this.setState({
dollars: this.state.dollars + 10
}, () => {
console.log('Here state will always be updated to latest version!');
console.log('State after (_onClickHandler): ' + JSON.stringify(this.state));
});
}
import 'babel-polyfill'
//dont forget to import babel-polyfill for this Set
[... new Set(this.props.data.map(e => e.gender))]
let data = [
{
id: 1,
name: 'test',
category: 'Kitchen'
},
{
id: 2,
name: 'Bacon',
category: 'Fork'