Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
676 B
4
Indexable
Never
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>
}


Leave a Comment