Last active
December 17, 2022 12:45
-
-
Save anna-llorens/95b975a6f0798a5c6552859e5f083762 to your computer and use it in GitHub Desktop.
Easily rearange sections using a Hook POC
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
// Types | |
enum DefaultSectionOrder { | |
Feedback, | |
Header, | |
} | |
enum variant1 { | |
Header, | |
Feedback, | |
} | |
// Give random order | |
export const useOrderComponents = () => Math.floor(Math.random() * 2) ? DefaultSectionOrder | variant1; | |
// useOrderComponents Hook | |
const MyFooComponent = () => { | |
const {order} = useOrderComponents(); | |
return <> | |
<Feedback $order={order.Feedback}/> | |
<Header $order={order.Header}/> | |
</> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment