Skip to content

Instantly share code, notes, and snippets.

@jcarroll2007
Last active March 23, 2021 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcarroll2007/6ae8f6433f36c8f6c54f3fe44deb46a7 to your computer and use it in GitHub Desktop.
Save jcarroll2007/6ae8f6433f36c8f6c54f3fe44deb46a7 to your computer and use it in GitHub Desktop.
React Architecture Blog Post: Character List component
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