Browse Source

Fix DOM structure in example

main
Dan Abramov 2 years ago
parent
commit
406fdc9197
  1. 48
      beta/src/content/learn/choosing-the-state-structure.md

48
beta/src/content/learn/choosing-the-state-structure.md

@ -581,8 +581,8 @@ import { initialTravelPlan } from './places.js';
function PlaceTree({ place }) { function PlaceTree({ place }) {
const childPlaces = place.childPlaces; const childPlaces = place.childPlaces;
return ( return (
<> <li>
<li>{place.title}</li> {place.title}
{childPlaces.length > 0 && ( {childPlaces.length > 0 && (
<ol> <ol>
{childPlaces.map(place => ( {childPlaces.map(place => (
@ -590,7 +590,7 @@ function PlaceTree({ place }) {
))} ))}
</ol> </ol>
)} )}
</> </li>
); );
} }
@ -832,8 +832,8 @@ function PlaceTree({ id, placesById }) {
const place = placesById[id]; const place = placesById[id];
const childIds = place.childIds; const childIds = place.childIds;
return ( return (
<> <li>
<li>{place.title}</li> {place.title}
{childIds.length > 0 && ( {childIds.length > 0 && (
<ol> <ol>
{childIds.map(childId => ( {childIds.map(childId => (
@ -845,7 +845,7 @@ function PlaceTree({ id, placesById }) {
))} ))}
</ol> </ol>
)} )}
</> </li>
); );
} }
@ -1186,15 +1186,13 @@ function PlaceTree({ id, parentId, placesById, onComplete }) {
const place = placesById[id]; const place = placesById[id];
const childIds = place.childIds; const childIds = place.childIds;
return ( return (
<> <li>
<li> {place.title}
{place.title} <button onClick={() => {
<button onClick={() => { onComplete(parentId, id);
onComplete(parentId, id); }}>
}}> Complete
Complete </button>
</button>
</li>
{childIds.length > 0 && {childIds.length > 0 &&
<ol> <ol>
{childIds.map(childId => ( {childIds.map(childId => (
@ -1208,7 +1206,7 @@ function PlaceTree({ id, parentId, placesById, onComplete }) {
))} ))}
</ol> </ol>
} }
</> </li>
); );
} }
``` ```
@ -1530,15 +1528,13 @@ function PlaceTree({ id, parentId, placesById, onComplete }) {
const place = placesById[id]; const place = placesById[id];
const childIds = place.childIds; const childIds = place.childIds;
return ( return (
<> <li>
<li> {place.title}
{place.title} <button onClick={() => {
<button onClick={() => { onComplete(parentId, id);
onComplete(parentId, id); }}>
}}> Complete
Complete </button>
</button>
</li>
{childIds.length > 0 && {childIds.length > 0 &&
<ol> <ol>
{childIds.map(childId => ( {childIds.map(childId => (
@ -1552,7 +1548,7 @@ function PlaceTree({ id, parentId, placesById, onComplete }) {
))} ))}
</ol> </ol>
} }
</> </li>
); );
} }
``` ```

Loading…
Cancel
Save