Last active
March 23, 2021 12:55
-
-
Save jcarroll2007/6ae8f6433f36c8f6c54f3fe44deb46a7 to your computer and use it in GitHub Desktop.
React Architecture Blog Post: Character List component
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
import React from 'react'; | |
import { Character } from '../../api/types'; | |
import { | |
Wrapper, | |
List, | |
ListItem, | |
ListItemInfo, | |
NameWrapper, | |
IsJediWrapper, | |
HeaderTypography | |
} from './styles' | |
interface CharacterListProps { | |
characters: Character[] | |
} | |
export const CharacterList: React.FunctionComponent<CharacterListProps> = ({ | |
characters, | |
}) => { | |
return ( | |
<Wrapper> | |
Star Wars Characters | |
<List> | |
<ListItem> | |
<NameWrapper> | |
<HeaderTypography> | |
Name | |
</HeaderTypography> | |
</NameWrapper> | |
<ListItemInfo> | |
<HeaderTypography> | |
Age | |
</HeaderTypography> | |
</ListItemInfo> | |
<IsJediWrapper> | |
<HeaderTypography> | |
isJedi | |
</HeaderTypography> | |
</IsJediWrapper> | |
</ListItem> | |
{characters.map((c) => ( | |
<ListItem key={c.name}> | |
<NameWrapper> | |
{c.name} | |
</NameWrapper> | |
<ListItemInfo> | |
{c.age} | |
</ListItemInfo> | |
<IsJediWrapper> | |
{c.isJedi ? 'True' : 'False'} | |
</IsJediWrapper> | |
</ListItem> | |
))} | |
</List> | |
</Wrapper> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment