Skip to content

Instantly share code, notes, and snippets.

View Venugopal46's full-sized avatar

Venugopal Venugopal46

View GitHub Profile
@jsjoeio
jsjoeio / index.ts
Last active July 12, 2021 14:59
Timezone related functions
import {
fromUnixTime,
format,
} from "date-fns"
/**
* Checks if a timezone string is valid or not
*
* We do this to catch typos.
*
import { useEffect, useRef } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { UnregisterCallback } from 'history';
/**
* Hook auxiliar. Referência para implementação:
* - https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state;
* - https://usehooks.com/usePrevious/;
@elijahmanor
elijahmanor / common-react-bugs.md
Last active May 29, 2019 19:51
Common Bugs when Learning React

Common Bugs when Learning React

The following list tries to summarize some of the things that a developer may encounter while learning React. The list focuses on scenarios that result in actual bugs (things that don't work) or things that cause warnings in the console.

  • using class prop instead of className (for/htmlFor, etc...)
  • trying to set the style prop with a string
  • not having a parent element or fragment
  • not binding (at all or incorrectly)
  • using the wrong lifecycle hook
  • misspelling componentWillReceiveProps
@sebmarkbage
sebmarkbage / react_legacyfactory.md
Last active March 15, 2020 00:32
Use a factory or JSX

React Element Factories and JSX

You probably came here because your code is calling your component as a plain function call. This is now deprecated:

var MyComponent = require('MyComponent');

function render() {
 return MyComponent({ foo: 'bar' }); // WARNING
@ecarter
ecarter / mapOrder.js
Created December 2, 2011 15:40
Order an array of objects based on another array order
/**
* Sort array of objects based on another array
*/
function mapOrder (array, order, key) {
array.sort( function (a, b) {
var A = a[key], B = b[key];