Skip to content

Instantly share code, notes, and snippets.

View bitttttten's full-sized avatar
👻
hello

Aaron Harding bitttttten

👻
hello
View GitHub Profile
@bitttttten
bitttttten / index.md
Created June 7, 2024 15:03 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

export default function transformer(file, api, options) {
const j = api.jscodeshift;
const root = j(file.source);
const removeIfUnused = (importSpecifier, importDeclaration) => {
const varName = importSpecifier.value.local.name;
if (varName === "React") {
return false;
}
@bitttttten
bitttttten / .env
Last active June 16, 2024 22:21
Fetch Spotify Recently Played from Netlify function
SPOTIFY_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxx
SPOTIFY_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxx
SPOTIFY_REFRESH_TOKEN=aaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-cccccccccccccccc-dddddddddddddddd-eeeeeeeeeeeeeeee
@bitttttten
bitttttten / Learnings
Last active January 15, 2020 13:49
2020 learnings
# CSS-in-JS
## Avoid facepaint, just use object syntax.
{
color: `blue`,
[mq.large]: {
color: `red`,
},
}
@bitttttten
bitttttten / index.js
Created June 16, 2019 15:04
useEffect and syncing
import { useEffect, useRef, useState } from 'react';
export default function AjaxToggle() {
const [checked, setChecked] = useState(false);
const firstRender = useRef(true);
function syncWithServer(checked) {
// ...
}
@bitttttten
bitttttten / .gitlab-ci.yml
Last active March 3, 2017 19:39
transaction testing with Nightmare.js and chai template (pseudo code)
image: node:7.7.1
stages:
- test
before_script:
- npm set progress=false
- npm install > npm-install.log 2>&1
transaction testing:
@bitttttten
bitttttten / app.js
Created December 2, 2016 22:51
mobx app observer with authentication
const App = observer(({ store }) => {
const { authenticated } = store
if (!authenticated ) {
return <Login
doLogin={store.login}
postLogin={store.showHomepage}
/>
}
@bitttttten
bitttttten / loaders.js
Created November 14, 2016 13:49
webpack loaders. because you only want to write this -once-
module.exports = [
{
test: /\.jsx?$/,
loader: 'babel',
},
{
test: /\.css$/,
loader: 'style-loader!css-loader',
},
{
const webpack = require('webpack');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const loaders = require('./loaders.js')
module.exports = {
entry: [
require.resolve('webpack-dev-server/client') + '?/',
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const loaders = require('./loaders.js')
module.exports = {
bail: true,
target: 'web',
entry: './app/client.js',