Skip to content

Commit

Permalink
Add a simple character details listing
Browse files Browse the repository at this point in the history
  • Loading branch information
rkotze committed Dec 8, 2019
1 parent d0776b0 commit 65aed81
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/App.js
@@ -1,7 +1,7 @@
import React from "react";
import logo from "./assets/rebel_alliance_logo.png";
import "./App.css";
import { ListCharacters } from "./list-characters";
import { CharacterDetails } from "./character-details";

function App() {
return (
Expand All @@ -10,9 +10,7 @@ function App() {
<img src={logo} className="App-logo" alt="logo" />
Star Wars
</header>
<div>
Characters: <ListCharacters />
</div>
<CharacterDetails />
</div>
);
}
Expand Down
23 changes: 23 additions & 0 deletions src/character-details.js
@@ -0,0 +1,23 @@
import React, { useState } from "react";
import { ListCharacters } from "./list-characters";

export function CharacterDetails() {
const [character, setCharacter] = useState(null);

const charProps = character && Object.entries(character);
return (
<div>
Characters: <ListCharacters onChange={setCharacter} />
{charProps &&
charProps.map(([key, value]) => {
if (typeof value === "string")
return (
<p>
{key}: {value}
</p>
);
return null;
})}
</div>
);
}

0 comments on commit 65aed81

Please sign in to comment.