Skip to content

Instantly share code, notes, and snippets.

View chestozo's full-sized avatar

chestozo

  • Portugal
  • 06:29 (UTC +01:00)
View GitHub Profile
const added = [ 5, 6, 4 ]
const ar = [
{ id: 6, name: 'zzz' },
{ id: 1, name: 'aaa' },
{ id: 2, name: 'ccc' },
{ id: 5, name: 'yyy' },
{ id: 3, name: 'bbb' },
{ id: 4, name: 'xxx' },
]
@chestozo
chestozo / test.md
Last active May 28, 2021 17:43
How to fix react-dnd "Invariant Violation: Cannot call hover while not dragging." issue

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 June 6, 2020 14:16
How to disable prettier formatting for HTML files in VSCode
{
"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 April 15, 2020 15:07
Router params access from storybook story
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 16:13
Quick print props for component component =) Useful for Formik
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%;
(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)
}
steps:
- name: node:10.16.3
entrypoint: yarn
args: ['build']
@chestozo
chestozo / timer.js
Created June 5, 2019 10:27
Measure time after click
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
// 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);

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.