Feature / Add working notifications with only twitter for now (#102)

* Add working notifications with only twitter for now

* feat(notification-bar): I didnt copy from NP

* Make default browser visibility true

* feat(notifications): Collapse when no more notifications after closing one
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-02-18 19:21:07 -05:00
1 parent 11af8bfb5a
commit 40ec19a349
19 files changed
+497 -153

No files matched your search

@@ -0,0 +1,28 @@
import React, { createContext, useState, useEffect, useRef } from 'react';
export const SnackbarContext = createContext(null);
function SnackbarProvider({ children }) {
const [alert, setAlert] = useState(null);
const timer = useRef(null);
useEffect(() => {
if (alert) {
clearTimeout(timer.current);
timer.current = setTimeout(() => {
setAlert(null);
}, 1000);
}
return () => clearTimeout(timer.current);
}, [alert]);
const addAlert = (value) => setAlert(value);
return (
<SnackbarContext.Provider value={{ addAlert, alert }}>
{children}
</SnackbarContext.Provider>
);
}
export default SnackbarProvider;