How Can I include a Custom JavaScript in ReactJS and use Array of Object in that? I am trying to display a list of songs. So, I have created a file with the name songList.js and inside that, I have created an Array of objects how can I include it in my list.js file and use it inside that?
songList.js Code :-
const songList = [{
name: "All We Know",
artist: "The Chainsmokers ft. Phoebe Ryan",
album: "All We Know",
},
{
name: "Alone",
artist: "Alan Walker",
album: "Different World",
},
{
name: "Be Kind",
artist: "Marshmello & Halsey",
album: "Be Kind",
},
{
name: "Beach House",
artist: "The Chainsmokers",
album: "Sick Boy",
},
];
I am trying to do this but it is not working please tell me where I am wrong?
list.js code
import React, { Component } from 'react'
import './songList.js'
export class list extends Component {
render() {
return (
<div>
{songList[0].name}
</div>
)
}
}
export default list
export default songList), then import it usingimport songList from './songList.js'