Skip to content

Instantly share code, notes, and snippets.

View kerenren's full-sized avatar
:electron:
React-ing...

kerenren

:electron:
React-ing...
View GitHub Profile
// how to create a clockwise rotate animation with SwitchTransition and CSSTransition approach
// jsx
<div className="rotating-icon">
<SwitchTransition>
<CSSTransition
key={state ? 'faChevronDown' : 'faChevronUp'}
addEndListener={(node, done) => node.addEventListener('transitionend', done, false)}
classNames="rotate"
@kerenren
kerenren / preloadImgs.js
Created September 27, 2021 13:06
Preload images into caches in react
// exmpale to use Promise.all to preload all the iamges in the array to the app
// [loading, setLoading] = useState(false);
const cacheImages = async (srcArray) => {
const promises = await srcArray.map((src)=>{
return new Promise((resolve, reject) => {
const img = new Image();
img.src = src;
img.onload = resolve;
//set the hardware clock
sudo hwclock --set --date="2020-04-28 18:07:50"
// syncronise the system clock to the hardware clock
sudo hwclock -s