I’m trying to follow a React tutorial this code should render some buttons, but it isn’t happening. I’m using codepen.io to make the code and I can send the tutorial link if necessary.
JavaScript
x
38
38
1
const sounds = [
2
{
3
keyCode: 81,
4
keyTrigger: 'Q',
5
id: 'Heater-1',
6
url: 'https://s3.amazonaws.com/freecodecamp/drums/Heater-1.mp3'
7
},
8
{
9
keyCode: 87,
10
keyTrigger: 'W',
11
id: 'Heater-2',
12
url: 'https://s3.amazonaws.com/freecodecamp/drums/Heater-2.mp3'
13
}
14
];
15
16
function App(){
17
return (
18
<div className="app-div bg-info min-vh-100 text-white">
19
<div className="text-center">
20
{sounds.map((clip) => {
21
<Pad key={clip.id} clip = {clip}/>
22
})}
23
</div>
24
</div>
25
)
26
}
27
28
function Pad({clip}) {
29
return (
30
<div className="btn btn-secondary p-4 m-3">
31
<audio id={clip.keyTrigger} source = {clip.url}/>
32
{clip.keyTrigger}
33
</div>
34
);
35
}
36
37
ReactDOM.render(<App />, document.getElementById('app'))
38
Advertisement
Answer
You forgot return your Pad component.
JavaScript
1
4
1
{sounds.map((clip) => {
2
return <Pad key={clip.id} clip = {clip}/>
3
})}
4