Skip to content

Instantly share code, notes, and snippets.

View json9512's full-sized avatar
😁
Studying...

Daniel Junghyun Son json9512

😁
Studying...
View GitHub Profile
@json9512
json9512 / useQuery vs useQuery + useMutation + useEffect.js
Last active November 23, 2022 14:01
useQuery vs useQuery + useMutation + useEffect
import { QueryClient, QueryClientProvider, useMutation, useQuery } from "@tanstack/react-query";
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { debounce } from "lodash";
import { useCallback, useEffect, useState } from "react";
import './App.css';
const queryClient = new QueryClient();
// EX 1 - useQuery만 사용
const fetchData = async (offset = 0) => {
@json9512
json9512 / app.jsx
Last active October 14, 2022 08:00
react useRef test
import { useEffect, useRef, useState } from 'react';
/* 설명:
React Strict mode를 해제한 상태에서 테스트해봤습니다.
1. 페이지에 Increase 버튼이 있음. 누르면 onClick 함수 실행됨
2. 페이지가 렌더된 후, useEffect에서 setTimeout을 실행시킴. setTimeout은 2초 뒤 console에 출력함
3. JSX에 각 값들이 (x.a = 일반 JS 객체, code = react의 state, s.current = useRef를 통해 받은 객체의 current 값) 표시되도록 되어있음
*/
export default function Home() {
const s = useRef();
@json9512
json9512 / app.js
Last active October 12, 2022 04:53
this is a test
const test = () => {
console.log('test')
}
test();