Skip to content

Instantly share code, notes, and snippets.

View katesroad's full-sized avatar
🎯

Kate katesroad

🎯
View GitHub Profile
@katesroad
katesroad / clean_code.md
Created October 30, 2021 18:46 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@katesroad
katesroad / react useReducer
Created October 3, 2021 00:41
react useReducer
// change can be a function or an object
const reduderFn = (state, change) => ({
...state,
...(typeof change === 'function' ? change(state): action),
});
const Counter = ({step}) => {
const [count, setCount] = React.useReducer(reducerFn, 0);
@katesroad
katesroad / useGetTableData
Last active September 30, 2021 20:20
Pagination for react-query
import { useQuery } from "react-query";
const useGetTableData = () => {
const queryKey = ["table", "data"];
const queryFn = () =>
new Promise((resolve) =>
resolve({
data: [],
total: 100
})