View server.js
const express = require('express'); | |
require('babel-register')({ | |
ignore: /\/(build|node_modules|.svg)\//, | |
presets: ['env', 'react-app'] | |
}); | |
const universal = require('./universal'); | |
const app = express(); |
View code-snippets.json
{ | |
"Create a useState block": { | |
"prefix": ["useState", "us"], | |
"body": [ | |
"const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = React.useState(${2:initialState})" | |
], | |
"description": "Create a regular useState hook" | |
}, | |
"Create a useEffect block": { | |
"prefix": ["useEffect", "ue"], |
View Main.elm
module Main exposing (..) | |
import Browser | |
import Html exposing (..) | |
import Html.Attributes as A | |
import Html.Events as Events | |
import Http | |
main = |
View image-optimizer.js
import Pica from 'pica'; | |
const getImageFromFile = file => | |
new Promise(resolve => { | |
const reader = new FileReader(); | |
const image = new Image(); | |
reader.onload = async fileReaderEvent => { | |
image.onload = () => resolve(image); | |
image.src = await fileReaderEvent.target.result; | |
}; |
View webpack.config.js
const path = require('path'); | |
const config = { | |
// First, let's define an entry point for webpack to start its crawling. | |
entry: './src/index.js', | |
// Second, we define where the files webpack produce, are placed | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
}, |
View webpack.config.js
const path = require('path'); | |
const config = { | |
// First, let's define an entry point for webpack to start its crawling. | |
entry: './src/index.js', | |
// Second, we define where the files webpack produce, are placed | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
}, |
View webpack.config.js
const path = require('path'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const isProduction = process.env.NODE_ENV === 'production'; | |
const config = { | |
// First, let's define an entry point for webpack to start its crawling. | |
entry: './src/index.js', | |
// Second, we define where the files webpack produce, are placed | |
output: { |
View my-styles.less
@color: palevioletred; | |
.with-styles { | |
background-color: @color; | |
} |
View index.js
import './my-styles.less'; | |
document.querySelector('body').classList.add('with-styles'); | |
View TheBestPage.js
class SomePage extends React.Component { | |
async componentDidMount() { | |
const { apiState } = this.props; | |
apiState.pending(); | |
try { | |
const res = await fetch('/api/some-data'); | |
const data = await res.json(); | |
apiState.success(); | |
} catch (e) { | |
apiState.error(); |
NewerOlder