Skip to content

Commit

Permalink
Fix #2671: Showcase store theme in local storage (#2772)
Browse files Browse the repository at this point in the history
* Fix #2671: Showcase store theme in local storage

* Fix #2671: Showcase store theme in local storage

* Update _app.js
  • Loading branch information
melloware authored Nov 10, 2022
1 parent a5f2463 commit 26e6c00
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import '../styles/demo/demo.scss';
import Layout from '../components/layout/layout';
import { useEffect, useRef, useState } from 'react';
import fetchNews from '../service/NewsService';
import { useStorage } from '../components/lib/hooks/useStorage';

export default function MyApp({ Component }) {
const [dark, setDark] = useState(false);
const [theme, setTheme] = useState('lara-light-indigo');
const [theme, setTheme] = useStorage('lara-light-indigo', 'primereact-showcase-theme');
const [storedNews, setStoredNews] = useStorage('', 'primereact-news');
const [newsActive, setNewsActive] = useState(false);
const storageKey = 'primereact';
const announcement = useRef(null);

useEffect(() => {
Expand Down Expand Up @@ -48,7 +49,7 @@ export default function MyApp({ Component }) {
hiddenNews: announcement.current.id
};

localStorage.setItem(storageKey, JSON.stringify(item));
setStoredNews(item);
},
onThemeChange: (newTheme, dark) => {
setDark(dark);
Expand Down

0 comments on commit 26e6c00

Please sign in to comment.