Skip to content

Commit

Permalink
use useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahd93 committed Aug 3, 2020
1 parent b706360 commit 60bd695
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gsa/src/web/pages/reports/details/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import React, {useState} from 'react';
import React, {useState, useEffect} from 'react';

import styled from 'styled-components';

Expand Down Expand Up @@ -102,9 +102,11 @@ const Summary = ({

const [hostsCount, setHostsCount] = useState(0);

if (hosts?.counts?.all > hostsCount) {
setHostsCount(hosts.counts.all);
}
useEffect(() => {
if (isDefined(hosts?.counts?.all)) {
setHostsCount(hosts.counts.all);
}
}, [hosts]);

const filterString = isDefined(filter)
? filter.simple().toFilterString()
Expand Down

0 comments on commit 60bd695

Please sign in to comment.