Skip to content

Instantly share code, notes, and snippets.

View V-Gutierrez's full-sized avatar
⚕️
Computer Therapist

Victor Gutierrez V-Gutierrez

⚕️
Computer Therapist
View GitHub Profile
import React from 'react'
import RNRestart from 'react-native-restart'
import { ErrorScreen } from '~/newUI'
interface Props {
children: React.ReactNode
}
interface State {
error: boolean
@V-Gutierrez
V-Gutierrez / allowDebug.js
Created April 27, 2021 23:56
Allows RN network debug on chrome
GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;
//use it on anywhere in global scope
import React, { useMemo } from 'react'
import { Dimensions, StyleSheet } from 'react-native'
import { Divider } from 'react-native-elements'
import TextWithCircle from '~/components/TextWithCircle'
import { Colors, Spacing, Typography, View } from '~/newUI'
import format from '~/services/format'
interface Data {
value: number;
color: string;
shadow: {
backgroundColor: 'white',
borderRadius: 6,
borderWidth: 1,
borderColor: Colors.mercury,
shadowColor: 'rgba(0,0,0,0.7)',
shadowOffset: {
width: 0,
height: 2
},
const useMount = func => useEffect(() => func(), [])
const useInitialURL = () => {
const [url, setUrl] = useState(null)
const [processing, setProcessing] = useState(true)
useMount(() => {
const getUrlAsync = async () => {
// Get the deep link used to open the app
const initialUrl = await Linking.getInitialURL()
@V-Gutierrez
V-Gutierrez / Breadcrumb.tsx
Created August 24, 2021 14:23
Breadcrumb with routing and automatic generation
import { Breadcrumbs as MuiBreadcrumbs, Typography } from '@material-ui/core'
import { withRouter } from 'react-router'
import { ChevronMiniRight } from '~/assets/icons'
import * as H from 'history'
import { match } from 'react-router'
import { routes } from '~/views'
interface BreadcrumbsProps {
history: H.History
location: H.Location
import React, { useEffect, Fragment } from 'react';
import { withRouter } from 'react-router-dom';
function ScrollToTop({ history, children }) {
useEffect(() => {
const unlisten = history.listen(() => {
window.scrollTo(0, 0);
});
return () => {
unlisten();
import { GetRepositoryInfoDocument, useGetRepositoryInfoQuery } from 'queries/generated/hooks';
import { MockedProvider } from '@apollo/client/testing';
import { renderHook } from '@testing-library/react-hooks';
export const queryMock = [
{
request: {
query: GetRepositoryInfoDocument,
variables: {
@V-Gutierrez
V-Gutierrez / sentryfeedback.tsx
Created November 12, 2021 18:58
sentryfeedback
const submitFeedbackToSentry = async ({ eventId, name, email, comments }: SubmitFeedbackToSentryOptions) => {
const response = await fetch(`https://sentry.io/api/0/projects/{COMPANY}/${SENTRY_PROJECT}/user-feedback/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `DSN ${ENVS.SENTRY_DSN}`
},
body: JSON.stringify({
event_id: eventId,
name,
@V-Gutierrez
V-Gutierrez / Swiper.tsx
Created February 20, 2022 15:09
Using swiperJS in react TS
import React, { useRef, useState } from 'react'
// Import Swiper React components
import { Swiper, SwiperSlide } from 'swiper/react'
import 'swiper/swiper.min.css'
import 'swiper/components/pagination/pagination.min.css'
import 'swiper/components/navigation/navigation.min.css'
import './styles.scss'
import SwiperCore, { Navigation, Virtual } from 'swiper/core'
// install Swiper modules