What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-02-20 02:40:36
how to pause useState counter value react hoooks
import React, { useState, useEffect } from 'react'; const Timer = () => { const [seconds, setSeconds] = useState(0); const [isActive, setIsActive] = useState(false); function toggle() { setIsActive(!isActive); } function reset() { ... Add solution -
Javascript 2022-02-19 09:55:09
rimraf node.js
// A viable alternative to `rm -rf` // GLOBAL INSTALL AND USE FROM CLI // npm install rimraf --global > rimraf ./node_modules // OR LOCAL PROJECT INSTALL // > npm install rimraf --save rimraf(`./${userIdFolder}/`, () => console.log(`DELETED ./${... Add solution -
Javascript 2022-02-18 16:30:02
settimeout react native focus text input
const inputRef = useRef(null) In onSubmitEditing prop, include this: setTimeout(() => inputRef.current.focus(), 250); Ex: const onEnterKeyPressed = () => { ... setTimeout(() => inputRef.current.focus(), 100); ... } <TextInput ...... Add solution -
Html 2022-02-18 02:55:08
what is Mongoose
import express from 'express'; or const exporess = require('express'); import mongoose from 'mongoose'; or const mongoose = require('mongoose'); const app = express(); mongoose.connect('mongodb://localhost:27017/mongo-tree' , { useNewUrlParser: true, ... Add solution -
Other 2022-02-18 01:55:17
ionic 5 android hardware back button doesn't exit app
import { IonRouterOutlet, Platform } from '@ionic/angular'; import { Plugins } from '@capacitor/core'; const { App } = Plugins; ... constructor( private platform: Platform, private routerOutlet: IonRouterOutlet ) { this.platform.backButton.subscri... Add solution -
Other 2022-02-17 17:00:03
componentdidmount functional hook
import { useState, useEffect } from 'react'; function getWindowDimensions() { const { innerWidth: width, innerHeight: height } = window; return { width, height }; } export default function useWindowDimensions() { const [windowDimensions,... Add solution -
Javascript 2022-02-17 11:15:14
component did update hooks
import React, { useState, useEffect } from 'react'; function Example() { const [count, setCount] = useState(0); // Similar to componentDidMount and componentDidUpdate: useEffect(() => { // Update the document title using the browser API ... Add solution -
Javascript 2022-02-17 07:05:02
_.get alternative
//This Is my alternative to (lodash) _.get() method const get = (obj, path, def) => (() => typeof path === 'string' ? path.replace(/\[(\d+)]/g,'.$1') : path.join('.'))() .split('.') .filter(Boolean) .every(step => ((obj = obj[step]) !== u... Add solution