Skip to content

Commit 648ec27

Browse files
author
agonzalez97
committed
Fixed variable usdeState
1 parent 4eb41f9 commit 648ec27

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/src/progress-bar/ProgressBar.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState } from "react";
1+
import React, { useContext, useEffect, useState } from "react";
22
import styled, { ThemeProvider } from "styled-components";
33
import { spaces } from "../common/variables.js";
44
import useTheme from "../useTheme";
@@ -15,10 +15,13 @@ const DxcProgressBar = ({
1515
}: Props): JSX.Element => {
1616
const colorsTheme = useTheme();
1717
const backgroundType = useContext(BackgroundColorContext);
18+
const [valueProgressBar, setValueProgressBar] = useState(0);
1819

19-
const [valueProgressBar] = useState(
20-
value === null || value === undefined || value < 0 ? 0 : value >= 0 && value <= 100 ? value : 100
21-
);
20+
useEffect(() => {
21+
setValueProgressBar(
22+
value === null || value === undefined || value < 0 ? 0 : value >= 0 && value <= 100 ? value : 100
23+
);
24+
}, [value]);
2225

2326
return (
2427
<ThemeProvider theme={colorsTheme.progressBar}>

0 commit comments

Comments
 (0)