I am coding a practice react application in which I am exporting a primitive array with a separate file named data.js
export const data = [
{
type:"multiple",
difficulty:"easy",
category:"Entertainment: Film",
question:"The Queen song `A Kind Of Magic` is featured in which 1986 film?",
correct_answer:"Highlander",
incorrect_answers:["Flash Gordon","Labyrinth","Howard the Duck"]
},
{
type:"multiple",
difficulty:"easy",
category:"Entertainment: Film",
question:"Who plays Jack Burton in the movie "Big Trouble in Little China?"",
correct_answer:"Kurt Russell",
incorrect_answers:["Patrick Swayze","John Cusack","Harrison Ford"]
},
{
type:"multiple",
difficulty:"easy",
category:"Entertainment: Film",
question:"Which of these films is NOT set in Los Angeles?",
correct_answer:"RoboCop",
incorrect_answers:["Blade Runner","The Terminator","Predator 2"]
},
{
type:"multiple",
difficulty:"easy",
category:"Entertainment: Film",
question:"Who wrote and directed the 1986 film 'Platoon'?",
correct_answer:"Oliver Stone",
incorrect_answers:["Francis Ford Coppola","Stanley Kubrick","Michael Cimino"]
},
{
type:"multiple",
difficulty:"easy",
category:"Entertainment: Film",
question:"This movie contains the quote, "I feel the need ... the need for speed!"",
correct_answer:"Top Gun",
incorrect_answers:["Days of Thunder","The Color of Money","Cocktail"]
}
]
However when I import the file in my app as follows
import {data} from "./assets/data.jsx"
import Question from "./Question"
console.log(data)
incorrect_answers is empty array
However the strange thing is when I rename incorrect_array: to incorrectArray: then the value is exported correctly. I cannot seem to understand this behavior as I think it should export the array correctly the first time.
Any help regarding this is greatly appreciated.
Thank you
Rivi
0
Your file name is data.js
, but you are importing data.jsx
. It might be that the application has another file with data.jsx
where the field incorrect_answers
is empty