0x3d.Site
is designed for aggregating information.
check repository here
⏱️ use-timer
Simple timer turned into React Hooks. Read about Hooks feature.
Installation
npm i use-timer
With Yarn:
yarn add use-timer
Demo
🚀 Try last production version on Netlify!
https://use-timer.netlify.app/
Usage
Basic timer
import React from 'react';
import { useTimer } from 'use-timer';
const App = () => {
const { time, start, pause, reset, status } = useTimer();
return (
<>
<div>
<button onClick={start}>Start</button>
<button onClick={pause}>Pause</button>
<button onClick={reset}>Reset</button>
</div>
<p>Elapsed time: {time}</p>
{status === 'RUNNING' && <p>Running...</p>}
</>
);
};
Decremental timer
const { time, start, pause, reset, status } = useTimer({
initialTime: 100,
timerType: 'DECREMENTAL',
});
Timer with end time
const { time, start, pause, reset, status } = useTimer({
endTime: 30,
initialTime: 10,
});
Advance time
This works for all types of timer (incremental and decremental).
const { time, start, advanceTime } = useTimer({
initialTime: 20,
});
start();
advanceTime(10);
console.log(time); // 30
Callbacks
Some callback functions can be provided.
When time is over
const { time, start, pause, reset, status } = useTimer({
endTime,
onTimeOver: () => {
console.log('Time is over');
},
});
When time is updated
const { time, start, pause, reset, status } = useTimer({
endTime,
onTimeUpdate: (time) => {
console.log('Time is updated', time);
},
});
Configuration
The configuration and all its parameters are optional.
Property | Type | Default value | Description |
---|---|---|---|
autostart | boolean | false | Pass true to start timer automatically |
endTime | number | null | The value for which timer stops |
initialStatus | string | "STOPPED" | The initial status for the timer. Options are: "RUNNING", "PAUSED", and "STOPPED" |
initialTime | number | 0 | The starting value for the timer |
interval | number | 1000 | The interval in milliseconds |
onTimeOver | function | Callback function that is called when time is over | |
onTimeUpdate | function | Callback function that is called when time is updated | |
step | number | 1 | The value to add to each increment / decrement |
timerType | string | "INCREMENTAL" | The choice between a value that increases ("INCREMENTAL") or decreases ("DECREMENTAL") |
React
React is a JavaScript library for building user interfaces. It enables developers to create reusable components and manage complex application states efficiently. React is widely adopted for developing dynamic and responsive web applications.
React Community – React
Patterns.dev
React
Quick Start – React
Snack - React Native in the browser
React JavaScript Tutorial in Visual Studio Code
Overview · React Native
React Native · Learn once, write anywhere
React Conferences – React
React - CodeSandbox
GitHub - visgl/react-map-gl: React friendly API wrapper around MapboxGL JS
GitHub - PaulLeCam/react-leaflet: React components for Leaflet maps
GitHub - measuredco/puck: The visual editor for React
GitHub - mkosir/react-parallax-tilt: 👀 Easily apply tilt hover effect on React components - lightweight/zero dependencies (3kB)
GitHub - cypress-io/cypress: Fast, easy and reliable testing for anything that runs in a browser.
GitHub - pmndrs/react-three-fiber: 🇨🇭 A React renderer for Three.js
GitHub - dvtng/react-loading-skeleton: Create skeleton screens that automatically adapt to your app!
GitHub - framer/motion: Open source, production-ready animation and gesture library for React
GitHub - gregberge/loadable-components: The recommended Code Splitting library for React ✂️✨
GitHub - FormidableLabs/victory: A collection of composable React components for building interactive data visualizations
TW Elements integration with React - Free Examples & Tutorial
GitHub - TanStack/router: 🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
GitHub - remotion-dev/remotion: 🎥 Make videos programmatically with React
GitHub - rcbyr/keen-slider: The HTML touch slider carousel with the most native feeling you will get.
GitHub - reduxjs/redux: A JS library for predictable global state management
GitHub - bvaughn/react-error-boundary: Simple reusable React error boundary component
GitHub - remix-run/react-router: Declarative routing for React
GitHub - gaearon/overreacted.io: Personal blog by Dan Abramov.
GitHub - vitejs/vite: Next generation frontend tooling. It's fast!
GitHub - vercel/swr: React Hooks for Data Fetching
More on React
Programming Tips & Tricks
Code smarter, not harder—insider tips and tricks for developers.
Using Lua's Garbage Collector for Fine-Tuned Memory Management in Large Applications
#1
Leveraging Lua's Environment for Dynamic Code Execution and Security
#2
Mastering Lua's Table Manipulation: Advanced Techniques for Handling Large Data Sets
#3
Enhancing Code Readability and Debugging with Lua's Debug Library
#4
Leveraging Lua's Coroutines for Efficient Concurrency and Asynchronous Programming
#5
Leveraging Lua's Tail Call Optimization for Efficient Recursion and Avoiding Stack Overflow in Deep Recursive Functions
#6
Creating Custom Iterators in Lua for Traversing Complex Data Structures Like Graphs or Trees
#7
How to Maximize the Speed of Data Lookup in Lua Using Hash Tables and Optimized Table Management
#8
Advanced Techniques for Asynchronous Programming in Lua Using Coroutines for High-Performance Systems
#9
Mastering Efficient Memory Management in Lua with Weak Tables for Optimal Resource Utilization
#10
Error Solutions
Turn frustration into progress—fix errors faster than ever.
Visual Studio Crashes When Opening a File or Debugging a Project
#1
Visual Studio Cannot Connect to GitHub or Other Version Control System
#2
Visual Studio Freezes During Build or Debug Process
#3
Visual Studio Fails to Build Project with "Unable to Start Program" Error
#4
Visual Studio Shows "Cannot Open the Solution" Error Message When Opening a Project
#5
Visual Studio Crashes on Startup with "The application has encountered an error" Message
#6
Visual Studio Fails to Detect Changes in Files When Using Git Integration
#7
Visual Studio Crashes with "Unknown Exception" When Trying to Build Solution
#8
Visual Studio Hangs During Debugging with "Unable to Start Program" Error
#9
Visual Studio Fails to Load Solution with "The system cannot find the file specified" Error
#10
Shortcuts
The art of speed—shortcuts to supercharge your workflow.
Maximize Your Code Navigation with Cmd + Option + Left Arrow!
#1
Feel Like a Pro with Cmd + Control + D: Quickly View Definitions Like Never Before!
#2
Unlock Speed and Precision with Cmd + Shift + M: Maximize Your Productivity!
#3
Don’t Panic, Use Cmd + Option + I to Open the Developer Tools Now!
#4
Stop Wasting Time and Jump to Your File in an Instant with Cmd + Shift + O!
#5
Quickly Fix Your Code with ‘Cmd + Option + L’ for Instant Code Formatting!
#6
Transform Your Workflow with ‘Cmd + Shift + N’ to Open a New Window in No Time!
#7
Say Goodbye to Mouse: Master ‘Cmd + Shift + F’ to Search Your Entire Codebase!
#8
Struggling to Find Files? Hit ‘Cmd + P’ and Jump Right to Your File!
#9
Never Lose Your Progress Again: Use ‘Cmd + Z’ to Undo Mistakes Instantly!
#10
Made with ❤️
to provide resources in various ares.