Skip to content

Instantly share code, notes, and snippets.

View Flcwl's full-sized avatar
💭
want to balance

PR. Flcwl

💭
want to balance
View GitHub Profile
@gaearon
gaearon / uselayouteffect-ssr.md
Last active October 22, 2024 04:12
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@jatazoulja
jatazoulja / AuthContext.js
Created August 1, 2018 01:00
Context with HoC for consumer.
import React, { createContext, Component } from "react";
import { Auth } from "aws-amplify";
const AuthContext = createContext({
isAuthenticated: false,
isAuthenticating: true
});
class AuthProvider extends Component {
state = {
isAuthenticated: false,
@magicspon
magicspon / webpack.config.js
Created January 19, 2018 10:44
Webpack config - common chunks outputting arrow functions in generated js
/* global */
const webpack = require('webpack')
const path = require('path')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
const querystring = require('querystring')
const { removeEmpty } = require('webpack-config-utils')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
let BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
@cazala
cazala / guide.md
Created January 2, 2018 16:19 — forked from menduz/guide.md
Frontend React + TypeScript guidelines

Directory Structure

The sources of the project follows this structure:

/src
  /app
    /{domain}
      /actions.ts
 /actions.spec.ts
@ali-master
ali-master / README.md
Last active March 24, 2024 16:42
LocalStorage Utils

localStorage Utils

Using

var pryStorage = new localStorageDB();

Set

module.exports = {
plugins: {
precss: {},
autoprefixer: {
browsers: ['last 2 versions'],
},
},
};
@dailc
dailc / webviewcache.js
Last active March 28, 2021 15:41
[webvie缓存] webview和浏览器缓存机制 tags:webview,cache
## Expires,ETag,Cache-Control之间的关系
### Last-Modified
浏览器第一次请求资源时,服务器的返回状态时`200`,内容是对应的请求资源,同时头部中会有一个`Last-Modified`属性标识,记录此文件在服务器端最后的被修改的时间,格式为:
```
Last-Modified:Tue, 24 Feb 2009 08:01:04 GMT
```
浏览器第二次请求此url时(如果有缓存),根据Http协议,浏览器会向服务器发送`If-Modified-Since`报头,询问该时间后文件是否有被修改过。
客户端格式为:
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@mitrakmt
mitrakmt / serveStaticFiles.js
Created September 27, 2016 06:41
How to serve a static file in Node.js, without Express :)
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
mime = require("mime")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
@ludwig
ludwig / logger.js
Created August 25, 2016 10:10 — forked from transitive-bullshit/logger.js
winston logger with filename:linenumber
// NOTE: this adds a filename and line number to winston's output
// Example output: 'info (routes/index.js:34) GET 200 /index'
var winston = require('winston')
var path = require('path')
var PROJECT_ROOT = path.join(__dirname, '..')
var logger = new winston.logger({ ... })
// this allows winston to handle output from express' morgan middleware