Skip to content

Instantly share code, notes, and snippets.

Avatar
📱
sending gifs

jonasgroendahl

📱
sending gifs
View GitHub Profile
View useWebSockets.tsx
import {useEffect, useRef, useState} from 'react';
import io from 'socket.io-client';
type Props = {
userId: number;
enabled: boolean;
onConnected?: () => void;
};
type Message = {
View useInfiniteQuery.tsx
import React, {useState} from 'react';
import {
Button,
Dimensions,
FlatList,
SafeAreaView,
StyleSheet,
Text,
View,
} from 'react-native';
@jonasgroendahl
jonasgroendahl / PickerModal.tsx
Created Aug 10, 2020
Picker modal directly from the project
View PickerModal.tsx
import React, {useState, useEffect} from 'react';
import {Modal, View, StyleSheet} from 'react-native';
import {Picker} from '@react-native-community/picker';
import Typography from './Typography';
import IconButton from './IconButton';
import Icon from './Icon';
import {useTranslation} from '../context/Language';
import ThemeColors from '../utils/Colors';
type Props = {
View calendar.tsx
import React, {useState} from 'react';
import {View, TouchableOpacity} from 'react-native';
import {Agenda} from 'react-native-calendars';
import {Card, Avatar} from 'react-native-paper';
import Typography from '../components/Typography';
const timeToString = (time) => {
const date = new Date(time);
return date.toISOString().split('T')[0];
};
View Languageprovider.tsx
import React, {useState, useEffect, useContext} from 'react';
import en from '../lang/en.json';
import zh from '../lang/zh.json';
import * as RNLocalize from 'react-native-localize';
import App from '../App';
type LanguageContextType = {
hello: string;
};
View index.js
const fetch = require("node-fetch");
const qs = require("querystring");
const nodemailer = require("nodemailer");
const cron = require("node-cron");
const EMAIL = "";
const PASSWORD = "";
const searchWord = "canon eos rp";
@jonasgroendahl
jonasgroendahl / Profile.tsx
Last active Dec 28, 2020
Picker Modal Gist - React native
View Profile.tsx
import React, {useState} from 'react';
import {View, StyleSheet, ScrollView, Image} from 'react-native';
import Container from '../components/Container';
import Typography from '../components/Typography';
import Paper from '../components/Paper';
import Icon from '../components/Icon';
import TextField from '../components/TextField';
import Spacer from '../components/Spacer';
import Button from '../components/Button';
import Center from '../components/Center';
View useTracking.ts
import {useEffect, useState} from 'react';
import {Alert} from 'react-native';
import BackgroundGeolocation from '@mauron85/react-native-background-geolocation';
import {defaultLocation} from '../utils/vars';
import {getDistanceFromLatLonInKm} from '../utils/getDistance';
const useTracking = (isActive: boolean) => {
const [location, setLocation] = useState(defaultLocation);
const [history, setHistory] = useState<any>([]);
const [distance, setDistance] = useState<number>(0);
View fetch - get marketplace listings
const fetch = require("node-fetch");
const getData = async () => {
try {
const response = await fetch("https://www.facebook.com/api/graphql/", {
headers: {
"content-type": "application/x-www-form-urlencoded"
},
body:
"av=0&__user=0&__a=1&__dyn=7xeUmBwjbgmwCwRyWzEsheC1swgE98nwgU6C4UKewSAAwCxW4E2czobohxi2i3qcw9m7oqx61BwvU2Vwb-q3q5Voy6o2xwbG783pwKx-8wlU-cBweq0wXAy85iaxq3m7Eaoy15wJwBgK4oK227Ua831wLwKwFxe0H8-7Eox21uwjojxm&__csr=&__req=l&__beoa=0&__pc=PHASED%3ADEFAULT&dpr=2&__rev=1001662448&__s=aw8z00%3Asobw97%3Az0y5t9&__hsi=6788100950301358546-0&lsd=AVqtNhkO&jazoest=2748&__spin_r=1001662448&__spin_b=trunk&__spin_t=1580477913&fb_api_caller_class=RelayModern&fb_api_req_friendly_name=MarketplaceNewSearchFeedPaginationQuery&variables=%7B%22count%22%3A16%2C%22cursor%22%3A%22%7B%5C%22pg%5C%22%3A0%2C%5C%22b2c%5C%22%3A%7B%5C%22br%5C%22%3A%5C%22%5C%22%2C%5C%22it%5C%22%3A0%2C%5C%22hmsr%5C%22%3Afalse%2C%5C%22tbi%5C%22%3A0%7D%2C%5C%22c2c%5C%22%3A%7B%5C%22br%5C%22%3A%5C%22AboZViCziur4Ep
View code
const el = document.querySelector(".item");
let isResizing = false;
el.addEventListener("mousedown", mousedown);
function mousedown(e) {
window.addEventListener("mousemove", mousemove);
window.addEventListener("mouseup", mouseup);