const useInterval = (callback: Function, delay?: number | null) => {
const savedCallback = useRef<Function>(() => {});
useEffect(() => {
savedCallback.current = callback;
});
useEffect(() => {
if (delay !== null) {
This file contains 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
grep -v master // master 제외 | |
<!-- local branch 삭제 패턴 --> | |
```bash | |
git branch | grep "" | grep -v master | xargs git branch -D | |
``` | |
<!-- remote branch 삭제 패턴 --> | |
```bash |
This file contains 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
```ts | |
import { render as renderComponent } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event'; | |
export const render = ( | |
ui: React.ReactElement, | |
options?: Parameters<typeof renderComponent>[1], | |
) => { | |
const user = userEvent.setup(); | |
const result = renderComponent(ui, options); |
This file contains 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
body { | |
... | |
overscroll-behavior: none; < = overscroll 바운스 액션 막아줌 | |
} |
const personProxy = new Proxy(person, {
get: (obj, prop) => {
if (!obj[prop]) {
console.log(
`Hmm.. this property doesn't seem to exist on the target object`
);
} else {
console.log(`The value of ${prop} is ${obj[prop]}`);
}
useEffect(() => {
const sse = new EventSource('[YOUR_SSE_ENDPOINT_URL]',
{ withCredentials: true });
function getRealtimeData(data) {
// process the data here,
// then pass it to state to be rendered
}
sse.onmessage = e => getRealtimeData(JSON.parse(e.data));
sse.onerror = () => {
import Document, { Html, Head, Main, NextScript } from 'next/document';
import { ServerStyleSheet } from 'styled-components';
export default class MyDocument extends Document {
static async getInitialProps(ctx: any) {
const { renderPage } = ctx;
const initialProps = await Document.getInitialProps(ctx);
const sheet = new ServerStyleSheet();
- 컨테이너 생성
docker create [image]
- 컨테이너 시작
import {Platform, PermissionsAndroid} from 'react-native';
import {
launchCamera,
launchImageLibrary,
ImagePickerResponse,
} from 'react-native-image-picker';
export const onHandleCamera = async () => {
if (Platform.OS === 'android') {
NewerOlder