Next.js Discord

Discord Forum

flickering button (localstorage)

Unanswered
XotEmBotZ posted this in #help-forum
Open in Discord
I have this button in a layout.tsx. When even i change the page (within the same layout) the button flikers. is there a way to stop the flikering?

12 Replies

Here I want to refresh the pages (as those need refreshed localstorage content) but it dosent auto refreshes
Hello Anyone?
Can you capture that flicker in a gif or mp4?
Where is Button from, custom made or UI library component?
Button is from scadcn
@Raymond Where is `Button` from, custom made or UI library component?
Similar thing is happening in other compoenents in the project
I have tried using use hook from react but cant get it to work as any type of promise I make (already tried using useMemo with use) it just keeps rehitting the promise over and over without actually hitting it
The way I see it is
1. inDemo is false on first render, therefore the button's label is Delete ,
2. useEffect runs and triggers a rerender after calling setInDemo
3. inDemo is true on second render, therefore button's label is Delete Demo
If you remove your useEffect, I expect no flickering to occur
I would think about what I want this button to do and if it can be conditionally displayed, or separated into 2 button
Chum salmon
Or you can try putting this in the page and see if it works.
    const [hydrated, setHydrated] = useState(false);
    
    useEffect(() => {
        setHydrated(true);
    }, []);