Skip to content

Instantly share code, notes, and snippets.

@estevanmaito
estevanmaito / redux.js
Created March 8, 2019 14:54
Redux study implementation
// There area lot more checks in the Redux lib but this gets the point across.
function createStore(reducer, initialState) {
let currentState = initialState;
const listeners = [];
function getState() {
return currentState;
}
function subscribe(listener) {
@estevanmaito
estevanmaito / sharect-simple-2.html
Created February 5, 2020 17:55
The simplest way to start using Sharect 2.0
<script src="https://unpkg.com/[email protected]/dist/sharect.js"></script>
<script>
Sharect.init();
</script>
@estevanmaito
estevanmaito / sharect-complete-2.html
Created February 5, 2020 17:58
The complete API of Sharect 2.0
<script src="https://unpkg.com/[email protected]/dist/sharect.js"></script>
<script>
Sharect.config({
facebook: true,
twitter: true,
twitterUsername: 'estevanmaito',
backgroundColor: '#C53364',
iconColor: '#fff',
selectableElements: ['p']
}).init();
import { CSSTransition as ReactCSSTransition } from 'react-transition-group'
import { useRef, useEffect, useContext } from 'react'
const TransitionContext = React.createContext({
parent: {},
})
function useIsInitialRender() {
const isInitialRender = useRef(true)
useEffect(() => {
let urls = $('a').toArray().map(a => $(a).attr('href'))
let images = $('img').toArray().map(img => $(img).attr('src'))
let css = $('link[rel="stylesheet"]').toArray().map(css => $(css).attr('href'))
let js = $('script').toArray().map(js => $(js).attr('src'))