What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-29 04:48:03
how to clear state in react hooks
const { useState } = React; function signupUser() { return new Promise(resolve => { setTimeout(resolve, 1000); }); } const initialState = { username: "", email: "", password: "", passwordConfirmation: &qu... Add solution -
Javascript 2021-09-24 13:47:03
right click of mouse and block F12 key
Source: https://www.programmingquest.com/2018/08/prevent-right-click-of-mouse-and-block.html For preventing Right click Context menu: $(document).on("contextmenu", function (e) { e.preventDefault(); }); For preventing 'F12' and '... Add solution -
Other 2021-09-21 22:49:04
links and when you click on these link it will scroll the page to the respective section.
$("nav").find("a").click(function(e) { e.preventDefault(); var section = $(this).attr("href"); $("html, body").animate({ scrollTop: $(section).offset().top }); }); Add solution -
Javascript 2021-09-17 20:11:02
react convert excel to json
import React, { useState } from "react"; import "./App.css"; import * as XLSX from "xlsx"; class ExcelToJson extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(thi... Add solution -
Javascript 2021-09-16 21:47:02
js detect cmd+s
// To detect Cmd key pressed, check Event.key === 'Meta' document.querySelectorAll('#form').forEach(form => { let meta_pressed = false; form.addEventListener('keydown', e => { if ( e.key === 'Meta' ) { meta_pressed = true; } else if ( e.key... Add solution