Untitled
unknown
plain_text
2 years ago
676 B
11
Indexable
const BaseButton = () => {} // button bez CS
const Button = withClickstream(BaseButton) // button z CS
const useClickstreamEnabled = () => {
const isEnabled = useContext(SomeContext) // jakiś kontekst będziemy mieć skąd będziemy wiedzieć czy używamy CSa w danym projekcie czy nie
}
const withClickstreamOrWithout = (ComponentWithoutCS, ComponentWithCs, clickstreamId) => {
const csEnabled = useClickstreamEnabled()
return csEnabled ? <ComponentWithCs clickstreamId={clickstreamId} /> : <ComponentWithoutCS/>
}
const Alert = () => {
<Box>
{withClickstreamOrWithout(BaseButton, Button, "myButtonCSid")}
</Box>
}
Editor is loading...
Leave a Comment