Skip to content

Instantly share code, notes, and snippets.

View ThiagoDallacqua's full-sized avatar

Thiago Dallacqua ThiagoDallacqua

  • Palmas - Tocantins, Brazil
  • 04:40 (UTC -03:00)
View GitHub Profile
import React form 'react'
// ...
class MyDebouncedComponent extends React.Component {
// ...
debouncedOnChange({ param1, param2 }) {
clearTimeout(this.timer);
this.timer = setTimeout(() => {
// logic...
myVar += 1
console.log(myVar)
if (false) {
var myVar = 3
} else {
//nothing here
}
myOtherVar += 1
export default function register() {
if ('serviceWorker' in navigator) {
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) {
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
const flatten = arr => {
let flattenedArr = []
let finished = true
for (const iterator of arr) {
if (!Array.isArray(iterator)) {
flattenedArr.push(iterator)
} else {
flattenedArr = flattenedArr.concat(iterator)