File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
site/src/components/LicenseBanner Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { useActor } from "@xstate/react"
2
+ import { useContext , useEffect } from "react"
3
+ import { XServiceContext } from "../../xServices/StateContext"
4
+
5
+ export const LicenseBanner : React . FC = ( ) => {
6
+ const xServices = useContext ( XServiceContext )
7
+ const [ licenseState , licenseSend ] = useActor ( xServices . licenseXService )
8
+ const warnings = licenseState . context . licenseData . warnings
9
+
10
+ /** Gets license data on app mount because LicenseBanner is mounted in App */
11
+ useEffect ( ( ) => {
12
+ licenseSend ( "GET_LICENSE_DATA" )
13
+ } , [ licenseSend ] )
14
+
15
+ if ( warnings ) {
16
+ return < div > { warnings . map ( ( warning , i ) => < p key = { `${ i } ` } > { warning } </ p > ) } </ div >
17
+ } else {
18
+ return null
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments