Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-333 simplify reactive unmoderated data warning
- Loading branch information
1 parent
0c7d34b
commit 7163f50
Showing
1 changed file
with
8 additions
and
14 deletions.
There are no files selected for viewing
22 changes: 8 additions & 14 deletions
22
source/features/stake-pools/ui/consent/UnmoderatedDataConsentedContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import React, { useState } from 'react'; | ||
import { useObservableEffect } from '../../../../lib/mobx/react'; | ||
import { Observer } from 'mobx-react-lite'; | ||
import React from 'react'; | ||
import { useStakePools } from '../../context'; | ||
import UnmoderatedDataConsented from './UnmoderatedDataConsented'; | ||
|
||
export const UnmoderatedDataConsentedContainer = () => { | ||
const { store } = useStakePools(); | ||
const [showUnmoderatedData, setShowUnmoderatedData] = useState( | ||
store.showUnmoderatedData | ||
return ( | ||
<Observer> | ||
{() => | ||
store.showUnmoderatedData ? <UnmoderatedDataConsented /> : <span /> | ||
} | ||
</Observer> | ||
); | ||
|
||
// Observe and update consent flag | ||
useObservableEffect(() => { | ||
setShowUnmoderatedData(store.showUnmoderatedData); | ||
}); | ||
|
||
if (showUnmoderatedData) { | ||
return <UnmoderatedDataConsented />; | ||
} | ||
return null; | ||
}; |