dvtng / react-loading-skeleton

Create skeleton screens that automatically adapt to your app!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SkeletonTheme does not reload on parameter change

HannesPaa opened this issue · comments

commented

Describe the bug
When the parameter of the SkeletonTheme is changed it does not reload.

To Reproduce
I use a ThemeProvider on my project. So when the page is loaded the themeState is loaded. But before this is loaded it gives the SkeletonTheme first the light-theme.

<SkeletonTheme
   baseColor={themeState === "dark" ? "#0B101A" : "#ebebeb"}
   highlightColor={themeState === "dark" ? "#111827" : "#f5f5f5"}
>

Actual Behavior
when params changes the SkeletonTheme does not should reload. So even in dark mode it is showing the light version.

Expected Behavior
When params changes the SkeletonTheme should reload.

Versions

  • react-loading-skeleton version: 3.2.0
  • Browser version: Microsoft Edge Version 111.0.1661.41

Additional context
Maybe if the params are store in a useState Hook and are refreshed with an useEffect it solves the problem.

const [baseColor, setBaseColor] = useState<string>(styleOptions.baseColor)
useEffect(() => {
   setBaseColor(styleOptions.baseColor)
}, [styleOptions.baseColor])

Hey @HannesPaa, there are actually no useState or useMemo calls in the react-loading-skeleton codebase, so it should be "impossible" for the skeletons to use a stale value for baseColor / highlightColor.

I can help you debug this if you provide more of your code. A runnable repository / CodeSandbox would be ideal.

Closing due to lack of response and since this does not seem to be a react-loading-skeleton issue.