Skip to content

Commit fe57ac7

Browse files
Merge pull request #771 from supertokens/fix/flicker
fix: guides page images rendering issue
2 parents 1a32b5a + 4a7cea2 commit fe57ac7

File tree

3 files changed

+18
-33
lines changed

3 files changed

+18
-33
lines changed

v2/src/components/recipeBoxes/add_ons.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import React, {useState, useEffect} from "react";
1+
import React, { useState } from "react";
22
import "./recipeBox.css"
33

4-
type size = "small" | "large"
54

65
export default function Addons(props: { text: string, path: string, icon: string, img?: string }) {
7-
const [image, setImage] = useState({default: ""});
8-
const [imageOnHover, setImageOnHover] = useState({default: ""});
96
const [hover, setHover] = useState(false);
10-
useEffect(() => {
11-
setImage(require(`../../../static/img/guides/${props.icon}.svg`));
12-
setImageOnHover(require(`../../../static/img/guides/${props.icon}-orange.svg`));
13-
},);
7+
8+
const regularIconPath = `/img/guides/${props.icon}.svg`;
9+
const onHoverIconPath = `/img/guides/${props.icon}-orange.svg`;
1410

1511
const handleMouseOver = () => {
1612
setHover(true);
@@ -21,7 +17,7 @@ export default function Addons(props: { text: string, path: string, icon: string
2117

2218
return <a href={props.path} className={`recipe_box`} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut}>
2319
<div className="recipe_box__icon_wrapper">
24-
<img src={hover ? imageOnHover.default : image.default} alt={props.text} />
20+
<img src={hover ? onHoverIconPath : regularIconPath} alt={props.text} />
2521
</div>
2622
<div className="recipe_box__text">{props.text}</div>
2723
</a>

v2/src/components/recipeBoxes/authMode.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
import React, {useState, useEffect} from "react";
1+
import React, {useState } from "react";
22
import "./recipeBox.css"
33

4-
type size = "small" | "large"
4+
type Size = "small" | "large"
55

6-
export default function AuthMode(props: { text: string, size: size, path: string, icon: string, img?: string }) {
7-
const [image, setImage] = useState({default: ""});
8-
const [imageOnHover, setImageOnHover] = useState({default: ""});
9-
const [imageToShow, setImageToShow] = useState({default: ""});
6+
export default function AuthMode(props: { text: string, size: Size, path: string, icon: string, img?: string }) {
107
const [hover, setHover] = useState(false);
11-
useEffect(() => {
12-
setImage(require(`../../../static/img/guides/${props.icon}.svg`));
13-
setImageOnHover(require(`../../../static/img/guides/${props.icon}-orange.svg`));
14-
if(props.size == "large" && props.img) {
15-
setImageToShow(require(`../../../static/img/guides/${props.img}.png`))
16-
}
17-
}, [props.size]);
8+
9+
const regularIconPath = `/img/guides/${props.icon}.svg`;
10+
const onHoverIconPath = `/img/guides/${props.icon}-orange.svg`;
1811

1912
const handleMouseOver = () => {
2013
setHover(true);
@@ -25,7 +18,7 @@ export default function AuthMode(props: { text: string, size: size, path: string
2518

2619
return <a href={props.path} className={`recipe_box ${props.size}`} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut}>
2720
<div className="recipe_box__icon_wrapper">
28-
<img src={hover ? imageOnHover.default : image.default} alt={props.text} />
21+
<img src={hover ? onHoverIconPath : regularIconPath} alt={props.text} />
2922
</div>
3023
<div className="recipe_box__text">{props.text}</div>
3124
<div className="recipe_box__full_image">

v2/src/components/recipeBoxes/refs.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
import React, {useState, useEffect} from "react";
1+
import React, { useState } from "react";
22
import "./recipeBox.css"
33

4-
type size = "small" | "large"
5-
64
export default function Refs(props: { text: string, path: string, icon: string, img?: string }) {
7-
const [image, setImage] = useState({default: ""});
8-
const [imageOnHover, setImageOnHover] = useState({default: ""});
95
const [hover, setHover] = useState(false);
10-
useEffect(() => {
11-
setImage(require(`../../../static/img/guides/${props.icon}.svg`));
12-
setImageOnHover(require(`../../../static/img/guides/${props.icon}-orange.svg`));
13-
},);
6+
7+
const regularIconPath = `/img/guides/${props.icon}.svg`;
8+
const onHoverIconPath = `/img/guides/${props.icon}-orange.svg`;
149

1510
const handleMouseOver = () => {
1611
setHover(true);
1712
}
13+
1814
const handleMouseOut = () => {
1915
setHover(false);
2016
}
2117

2218
return <a href={props.path} className={`recipe_box`} onMouseOver={handleMouseOver} onMouseOut={handleMouseOut}>
2319
<div className="recipe_box__icon_wrapper">
24-
<img src={hover ? imageOnHover.default : image.default} alt={props.text} />
20+
<img src={hover ? onHoverIconPath : regularIconPath} alt={props.text} />
2521
</div>
2622
<div className="recipe_box__text">{props.text}</div>
2723
</a>

0 commit comments

Comments
 (0)