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
name: 'Hashnode Blogs' | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' # Runs every hour, on the hour. | |
jobs: | |
update_blogs: | |
name: 'Hashnode Latest Blogs' |
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
import { useLayoutEffect } from 'react'; | |
const useAutoSizeTextArea = ( | |
id: string, | |
textAreaRef: HTMLTextAreaElement | null, | |
value: string | |
) => { | |
// this will calculate the height of textArea before DOM paints | |
useLayoutEffect(() => { | |
const textArea = textAreaRef ?? document.getElementById(id); |
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
import { useCallback, useEffect, useState } from 'react'; | |
/** | |
* React hook to copy text to clipboard | |
* @param value the text to copy | |
* @param timeout delay (in ms) to switch back to initial state once copied. | |
* @param callBack execute when content is copied to clipboard | |
*/ | |
export const useClipboard = ( | |
value: string, |
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
import { useEffect, useRef, useState } from 'react'; | |
export const useElementInView = (options) => { | |
const elementRef = useRef(null); | |
const [isInView, setIsInView] = useState(false); | |
const handleObserve = (entries) => { | |
const [entry] = entries; |
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
// Let's say we have two objects i.e userPersonal and userSocial | |
// We want to merge these two objects and send the new object to the server. | |
const userPersonal = { | |
firstName:"Sachin", | |
lastName:"Chaurasiya", | |
email:"sachinchaurasiyachotey87@gmail.com", | |
} | |
const userSocial={ |
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
// Let's say we have one object i.e developer. | |
const developer={ | |
name:"Sachin Chaurasiya", | |
age:22, | |
githubHandle:"https://github.com/Sachin-chaurasiya", | |
portfolio:"https://sachinchaurasiya.dev", | |
blog:"https://blog.sachinchaurasiya.dev" | |
} |