Skip to content

Instantly share code, notes, and snippets.

View OkancanCosar's full-sized avatar
😎
Focusing To React-Native

OkancanCosar

😎
Focusing To React-Native
View GitHub Profile
@OkancanCosar
OkancanCosar / index.tsx
Created September 28, 2025 08:49
i18n Trans component example
<View style={{}}>
<Text>
<Trans
i18nKey="gift_message"
components={{
green: (
<Text style={{ color: 'green', fontWeight: '800' }}>
{''}
</Text>
),
@OkancanCosar
OkancanCosar / index.tsx
Last active April 7, 2025 10:15
useQuery cancel signal
import React, { useEffect, useRef } from 'react'
import { View } from 'react-native'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useIsFocused } from '@react-navigation/native'
export const MyScreen = () => {
const isFocused = useIsFocused();
const queryClient = useQueryClient();
const controllerRef = useRef<AbortController | null>(null);
@OkancanCosar
OkancanCosar / index.tsx
Created April 7, 2025 08:32
useMutation cancel signal
import React, { useEffect, useRef, useState } from 'react'
import { View } from 'react-native'
import { useMutation } from '@tanstack/react-query'
export const MyScreen = () => {
const [data, setData] = useState<number[]>([])
const controllerRef = useRef<AbortController | null>(null);
const getListMutation = useMutation({
mutationFn: async () => {
@OkancanCosar
OkancanCosar / index.js
Created January 18, 2024 13:05
percentage to hex color
const perc2color = (perc: number) => {
var r, g, b = 0;
if (perc < 50) {
r = 255;
g = Math.round(5.1 * perc);
}
else {
g = 255;
r = Math.round(510 - 5.10 * perc);
}