Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement