Skip to content

Commit 9aa9f04

Browse files
committed
add LicenseBanner that calls xservice
1 parent ead0ab4 commit 9aa9f04

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

0 commit comments

Comments
 (0)