This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Props = { | |
toWrap: boolean; | |
wrapper: (children: any) => any; | |
}; | |
export const ConditionalWrapper: React.FC<Props> = ({ toWrap, wrapper, children }) => { | |
return toWrap ? wrapper(children) : children; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useLocation } from 'react-router'; | |
const useQueryParams = (...keys: string[]) => { | |
const location = useLocation(); | |
const params = new URLSearchParams(location.search); | |
const values = keys.map((key) => params.get(key) ?? ''); | |
return values; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback, useState } from "react"; | |
const useForceRemount = () => { | |
const [key, setKey] = useState(Math.random()); | |
const forceRemount = useCallback(() => setKey((key) => key + 1), []); | |
return { mountKey: key, forceRemount }; | |
}; | |
export default useForceRemount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to use? | |
# commit_comment "YOUR_MESSAGE" | |
.commit-comment: | |
script: | |
- export GITLAB_TOKEN="PROJECT_ACCESS_TOKEN" | |
- | | |
commit_comment() { | |
curl --location --request POST "https://gitlab.agodadev.io/api/v4/projects/$CI_MERGE_REQUEST_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" --header "Content-Type: application/json" --data-raw "{ \"body\": \"$1\" }" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef, useState } from 'react'; | |
export function useDelayedProps<T>(props: T, duration: number): [boolean, T] { | |
const delayedProps = useRef(props); | |
const [toRerender, setToRerender] = useState(false); | |
useEffect(() => { | |
setToRerender(true); | |
const timeout = setTimeout(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useLayoutEffect, useState } from 'react'; | |
import isEqual from 'lodash/isEqual'; | |
export function useDelayedProps<T>(props: T, duration: number, idProp?: keyof T): T { | |
const [delayedProps, setDelayedProps] = useState(props); | |
useLayoutEffect(() => { | |
let timeout: NodeJS.Timeout; | |
const isPropEqual = idProp | |
? props[idProp] === delayedProps[idProp] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git | |
# -------------------------------- | |
alias g="git" | |
alias gi="git init" | |
alias gc="git commit -m" | |
alias gcnv="git commit --no-verify -m" | |
alias gcae="git commit --allow-empty -m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
function useRerenderAnimation<PropType>( | |
props: PropType, | |
initialAnimation: string, | |
renderAnimation: string, | |
renderDelay: number // in milliseconds, ideally should be equal to the duration of renderAnimation | |
) { | |
const [state, setState] = useState<PropType>(); | |
const [rendered, setRendered] = useState(true); |