Skip to content

Instantly share code, notes, and snippets.

@chestozo
chestozo / test.md
Last active May 28, 2021
How to fix react-dnd "Invariant Violation: Cannot call hover while not dragging." issue
View test.md

In our case were getting this issue before we moved the data-testid attribute onto Dropzone input props like this:

<Dropzone
  onDrop={onDrop}
  accept={accept}
  style={{}}
  onClick={onClick}
  inputProps={{
    'data-testid': 'drop-file-input',
@chestozo
chestozo / settings.json
Created Jun 6, 2020
How to disable prettier formatting for HTML files in VSCode
View settings.json
{
"files.autoSave": "onFocusChange",
"prettier.requireConfig": true,
"prettier.disableLanguages": [
"HTML"
],
"editor.formatOnSave": true,
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@chestozo
chestozo / storybook-router-params.js
Created Apr 15, 2020
Router params access from storybook story
View storybook-router-params.js
import React from 'react'
import { MemoryRouter, Route } from 'react-router'
export default {
title: 'UserCard',
decorators: [],
}
const UserCard = ({
match: {
@chestozo
chestozo / ShowProps.tsx
Last active May 15, 2020
Quick print props for component component =) Useful for Formik
View ShowProps.tsx
import React from 'react'
import styled from 'styled-components'
import { Box, TextBox } from 'ui-kit'
const Wrapper = styled(Box)`
position: fixed;
top: 0;
right: 0;
overflow: auto;
font-size: 80%;
View history-debug-wrapper.js
(function() {
const methods = [ 'pushState', 'replaceState', 'back', 'forward', 'go' ]
const _originals = {}
methods.forEach((m) => {
_originals[m] = window.history[m]
window.history[m] = function() {
console.log('XXX', m, arguments)
return _originals[m].apply(window.history, arguments)
}
View gcloud.yml
steps:
- name: node:10.16.3
entrypoint: yarn
args: ['build']
@chestozo
chestozo / timer.js
Created Jun 5, 2019
Measure time after click
View timer.js
document.addEventListener('click', () => {
const dt = Date.now();
const clockElement = document.createElement('div');
Object.assign(clockElement.style, {
position: 'absolute',
top: 0,
right: 0,
background: '#FAA',
'z-index': 9999,
padding: 5
View loadscript.js
// Part of manifest.js generated by webpack:
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.charset = 'utf-8';
script.async = true;
script.timeout = 120000;
script.crossOrigin = "anonymous";
if (__webpack_require__.nc) {
script.setAttribute("nonce", __webpack_require__.nc);
View fffile.md

Did you know that two spaces at the end of the line
are actually a line break? Do you see it?

And here is what you get without any spaces at end of the line.

View fat-arrow-class-method-example.js
class MyDuperClass {
onClick = () => {
this.doSomeStuff();
}
}