Skip to content

Instantly share code, notes, and snippets.

View andrei-cacio's full-sized avatar
👀
🤔 👀

Andrei Cacio andrei-cacio

👀
🤔 👀
View GitHub Profile
@andrei-cacio
andrei-cacio / clickoutside.jsx
Created March 2, 2019 08:37
ClickOutside structure
import React, { Component } from 'react';
class ClickOutside extends Component {
handleClick = e => {
console.log('clicking everywhere!');
};
componentDidMount() {
document.addEventListener("click", this.handleClick);
}
@andrei-cacio
andrei-cacio / clickoutside.jsx
Created March 2, 2019 08:37
ClickOutside structure
import React, { Component } from 'react';
class ClickOutside extends Component {
handleClick = e => {
console.log('clicking everywhere!');
};
componentDidMount() {
document.addEventListener("click", this.handleClick);
}
import React, { Component } from 'React';
import PropTypes from 'prop-types';
class ClickOutside extends Component {
static propTypes = {
onClick: PropTypes.func
}
constructor(props) {
super(props);
import React, { Component } from 'React';
import PropTypes from 'prop-types';
class ClickOutside extends Component {
static propTypes = {
onClick: PropTypes.func
}
constructor(props) {
super(props);
import React from 'react';
function ClickOutside({ children, onClick }) {
const refs = React.Children.map(children, () => React.createRef());
const handleClick = e => {
const isOutside = refs.every(ref => {
return !ref.current.contains(e.target);
});
if (isOutside) {
@andrei-cacio
andrei-cacio / clickoutside.jsx
Last active March 8, 2019 08:26
ClickOutside Hook
import React, { Component, useEffect } from "react";
function ClickOutside({ children, onClick }) {
const refs = React.Children.map(children, () => React.createRef());
const handleClick = e => {
const isOutside = refs.every(ref => {
return !ref.current.contains(e.target);
});
if (isOutside) {
onClick();
@andrei-cacio
andrei-cacio / click-outide.jsx
Last active March 28, 2019 17:43
Clickoutside updated
import React, { Component, useEffect, useCallback } from "react";
function ClickOutsideH({ children, onClick }) {
const refs = React.Children.map(children, () => React.createRef());
const handleClick = useCallback(e => {
const isOutside = refs.every(ref => {
return !ref.current.contains(e.target);
});
if (isOutside) {
onClick();
@andrei-cacio
andrei-cacio / db.js
Created June 22, 2019 07:34
nodeschool-db
export default [
{
id: 54590991,
node_id: "MDEwOlJlcG9zaXRvcnk1NDU5MDk5MQ==",
name: "cluj",
full_name: "jsheroes/cluj",
private: false,
owner: {
login: "jsheroes",
id: 16759725,
@andrei-cacio
andrei-cacio / chrome-paste.html
Last active August 29, 2019 10:30
Pasting hello world in Chrome
<meta charset='utf-8'>
<span style="
color: rgb(0, 0, 0);
font-family: Times;
font-size: medium;
font-style: normal;
font-variant-ligatures: normal;
font-variant-caps: normal;
font-weight: 400;
letter-spacing: normal;
@andrei-cacio
andrei-cacio / safari-paste.html
Created August 29, 2019 10:31
Pasting hello world in Safari
<span style="
font-family: -webkit-standard;
font-style: normal;
font-variant-caps: normal;
font-weight: normal;
letter-spacing: normal;
orphans: auto;
text-align: start;
text-indent: 0px;
text-transform: none;