Skip to content

Commit 78b6f8f

Browse files
committed
Make object data easier for translation
1 parent 84f29eb commit 78b6f8f

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/content/learn/conditional-rendering.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -719,24 +719,16 @@ Another solution would be to remove the condition altogether by moving the infor
719719
<Sandpack>
720720
721721
```js
722-
const drinks = {
723-
tea: {
724-
part: 'leaf',
725-
caffeine: '15–70 mg/cup',
726-
age: '4,000+ years'
727-
},
728-
coffee: {
729-
part: 'bean',
730-
caffeine: '80–185 mg/cup',
731-
age: '1,000+ years'
732-
}
733-
};
722+
const drinks = [
723+
{name: 'tea', part: 'leaf', caffeine: '15–70 mg/cup', age: '4,000+ years'},
724+
{name: 'coffee', part: 'bean', caffeine: '80–185 mg/cup', age: '1,000+ years'}
725+
];
734726

735727
function Drink({ name }) {
736-
const info = drinks[name];
728+
const info = drinks.find(d => d.name === name);
737729
return (
738730
<section>
739-
<h1>{name}</h1>
731+
<h1>{info.name}</h1>
740732
<dl>
741733
<dt>Part of plant</dt>
742734
<dd>{info.part}</dd>

0 commit comments

Comments
 (0)