Skip to content

Commit 249ae94

Browse files
authored
Merge pull request #147 from infinum/fix-randomized-images
Fix images issue on showcase
2 parents 3975a16 + e644af3 commit 249ae94

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

website/src/theme/sections/showcase-grid/showcase-grid.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ export default function ShowcaseGrid() {
9494
},
9595
]);
9696

97+
// https://reactjs.org/docs/react-dom.html#hydrate
98+
const [isClient, setIsClient] = useState(false);
99+
useEffect(() => {
100+
setIsClient(true)
101+
}, []);
102+
97103
const items = itemsData.map((item, index) => {
98104
const {
99105
image,
@@ -130,8 +136,9 @@ export default function ShowcaseGrid() {
130136
)
131137
});
132138

139+
/* key={isClient ? 1 : 2} will trigger a rerender of the whole subtree and the images will be aligned with text */
133140
return (
134-
<div className={component}>
141+
<div className={component} key={isClient ? 1 : 2}>
135142
<Container
136143
componentClass={component}
137144
>

0 commit comments

Comments
 (0)