TIL

[TIL] 20211209 react-query/select tag value/react-table-sticky

자바칩 프라푸치노 2021. 12. 14. 10:23

1. react-query

https://blog.rhostem.com/posts/2021-02-01T00:00:00.000Z

 

blog.rhostem.com

프론트엔드 웹 개발 기술 블로그

blog.rhostem.com

https://shindongri.dev/blog/react-query-14/

 

React Query:Mutations

쿼리와 달리 뮤테이션은 데이터 CUD 에 사용된다. 이 목적으로 리액트 쿼리는 useMutation 훅을 제공한다. function App() { const mutation = useMutation(newTodo => axios.post('/todos', newTodo)) return ( {mutation.isLoading ? (

shindongri.dev

https://merrily-code.tistory.com/76

 

[번역] : React Query - 왜, 그리고 어떻게 사용할 수 있을까?

이 글은 Nathan Sebhastian 님의 How and Why You Should Use React Query 를 번역한 글입니다. 요즘은 axios 와 더불어 react query 역시 많이 쓴다는 말을 들어서... 큰 개념만 정리해보고자 번역을 진행해 봤습..

merrily-code.tistory.com

https://www.zigae.com/react-query-key/

 

React Query Key 관리

queryKey는 React Query에서 중요한 개념이다. 내부적으로 데이터를 캐시하고 쿼리에 대한 종속성이 변경될 때 자동으로 다시 가져올 수 있게 한다.

www.zigae.com

리액트 쿼리는 처음 접했을때 잘 이해가 안갔다. 

리덕스 대신에 사용한다고 하는데 서버에서 데이터를 관리하는 것과

클라이언트에서 전역으로 데이터를 관리하는 게 왜 대체될 수 있는 건지 이해가 안갔다. 

다른 곳에서 찾아보니 클라이언트에서만 필요한 전역 데이터를 관리할 수 있게 가벼운 라이브러리를 함께 사용하면 좋다고 한다. 

한편 , 리덕스를 사용해서 서버 데이터를 받아와서 post, put, delete하는 메소드를 사용할 때

화면에 바로 업데이트 할 수 있던 것을 mutation으로 한다고 한다.

더 공부해봐야겠다. 

 

 

2. defaultValue error

https://sso-feeling.tistory.com/735

 

[에러노트] Failed form propType: You provided a `value` prop to a form field without an `onChange` handler

select 태그에 value를 넘겨주면 에러가 난다. defaultValue로 바꿔주어야함 { accessor: "ifSoldout", Header: "일시 품절시", Cell : (props) => 미송 환불 },

sso-feeling.tistory.com

 

 

3.  table에서 왼쪽에 컬럼을 고정하고 싶을때

https://github.com/GuillaumeJasmin/react-table-sticky

 

GitHub - GuillaumeJasmin/react-table-sticky: Sticky hook for react-table v7

Sticky hook for react-table v7. Contribute to GuillaumeJasmin/react-table-sticky development by creating an account on GitHub.

github.com

스타일을 지정하지 않으면 투명하게 넘어간다.

const tdStyle = css`
text-align: center;
padding: 10px;
border: 1px solid #e3e3e3;
height: auto;
background: inherit;
`;
const trStyle = css`
tr:nth-child(odd) {
  background: #f3f3f3;
}
tr:nth-child(even){
  background: white;
}

td와 th에 background를 지정해주면 된다.

 

728x90