SHARE
TWEET

Untitled

a guest Aug 25th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { useEffect, useState } from 'react';
  2. import temp from './template.json';
  3.  
  4. function addCustomCss(url) {
  5.   const link = document.createElement('link');
  6.   link.setAttribute('rel', 'stylesheet');
  7.   link.setAttribute('type', 'text/css');
  8.   link.setAttribute('href', url);
  9.   document.getElementsByTagName('head')[0].appendChild(link);
  10. }
  11.  
  12. export function useCss() {
  13.   useEffect(() => {
  14.     addCustomCss('/styles/style.css');
  15.   }, []);
  16. }
  17.  
  18. const LoadJsons = async () => {
  19.   return temp;
  20. };
  21.  
  22. export function useTemplate() {
  23.   const [template, setTemplate] = useState(null);
  24.  
  25.   useEffect(() => {
  26.     LoadJsons().then((res) => {
  27.       setTemplate(res);
  28.     });
  29.   }, [template]);
  30.   return template;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top