Skip to content

Instantly share code, notes, and snippets.

@JacksonBates
Created January 28, 2022 05:24
Show Gist options
  • Save JacksonBates/8c350261df2a217c187e48ea3a1c373b to your computer and use it in GitHub Desktop.
Save JacksonBates/8c350261df2a217c187e48ea3a1c373b to your computer and use it in GitHub Desktop.
import​ ​{
​  ​RadioSelect​,
​  ​Text​,
​}​ ​from​ ​"components"​;
 
​export​ ​default​ ​function​ ​FormItem​(​{data})​ ​{
​  ​const​ ​itemType​ ​=​ ​data​.​item_type​;
​  ​const​ ​componentMap​ ​=​ ​{
​    ​radio​: ​RadioSelect​,
​    ​text​: ​Text​, 
​  ​}​;
​ 
   ​const​ ​ItemComponent​ ​=​ ​componentMap​[​itemType​]​;
​ 
 ​return​ ​(
​    ​<​ItemComponent
​      ​item​=​{​data​}
​    ​/​>
​  ​)​;
​}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment