const handlePress = useCallback(() => {
// handle press
}, [])
<Button onPress={handlePress} />
| import { createContext, useContext } from 'react' | |
| import { createStore, StoreApi } from 'zustand' | |
| import { immer } from 'zustand/middleware/immer' | |
| import { useStoreWithEqualityFn } from 'zustand/traditional' | |
| type State = { | |
| total: number | |
| increase: () => void | |
| decrease: () => void |
| /* An example app that uses expo-auth-session to connect to Azure AD (or hopefully most providers) | |
| Features: | |
| - secure cache with refresh on load | |
| - securely stored refresh token using expo-secure-store | |
| - uses zustand for global access to the token / logout | |
| Based on [this gist](https://gist.github.com/thedewpoint/181281f8cbec10378ecd4bb65c0ae131) | |
| */ |
| <!-- | |
| * Copyright (c) 2021 GraphQL Contributors | |
| * All rights reserved. | |
| * | |
| * This code is licensed under the MIT license. | |
| * Use it however you wish. | |
| --> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> |
| let Uploaders = {} | |
| Uploaders.S3 = function (entries, onViewError) { | |
| entries.forEach(entry => { | |
| let xhr = new XMLHttpRequest() | |
| onViewError(() => xhr.abort()) | |
| xhr.onload = () => (xhr.status === 200 ? entry.done() : entry.error()) | |
| xhr.onerror = () => entry.error() | |
| xhr.upload.addEventListener("progress", event => { | |
| if (event.lengthComputable) { |
| import React, { | |
| useCallback, | |
| useEffect, | |
| useMemo, | |
| useRef, | |
| useState, | |
| } from 'react'; | |
| import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; | |
| import BottomSheet from '@gorhom/bottom-sheet'; | |
| import { SafeAreaProvider } from 'react-native-safe-area-context'; |
| const { Socket } = require('@supabase/realtime-js'); | |
| const WebSocket = require('ws'); | |
| const wss = new WebSocket.Server({ port: 3000 }); | |
| wss.on('connection', function connection(ws) { | |
| ws.send('Connection established.'); | |
| }); | |
| const socket = new Socket(process.env.REALTIME_URL || 'http://localhost:4000/socket') |
| # | |
| # Delete previous function definition (if exists) | |
| # | |
| DROP FUNCTION IF EXISTS before_update_updated_at() CASCADE; | |
| # | |
| # Create function to update updated_at timestamp if changed values on update | |
| # | |
| CREATE OR REPLACE FUNCTION before_update_updated_at() RETURNS trigger AS | |
| $BODY$ |
| export default { | |
| name: 'department', | |
| type: 'document', | |
| title: 'Department', | |
| fields: [ | |
| { | |
| name: 'title', | |
| type: 'string', | |
| title: 'Title', | |
| }, |
| import { HttpLink } from 'apollo-link-http'; | |
| import { ApolloClient, DefaultOptions } from 'apollo-client'; | |
| import { InMemoryCache, NormalizedCacheObject } from 'apollo-cache-inmemory'; | |
| import { ApolloLink } from 'apollo-link'; | |
| import { resolvers } from './resolvers'; | |
| import { typeDefs } from './schema/typeDefs'; | |
| import { errorLink } from './error'; | |
| import { requestLink } from './requestLink'; | |
| import customFetch from './customFetch'; |