I'm currently creating a React app, and in it I want to be able to reference an array of values in any file I import the array. However, I want the array to be filled with values that are passed from another file via props. How can I do this? My array will always have the same number of values. Currently, my App.js file is structured something like this:
App.js:
import React from 'react'
import Array from './Array'
function App() {
return (
<div>
<Array valOne="7" valTwo="10" valThree="2" valFour="19"/>
</div>
);
}
Essentially, I want to be able to call <Array />
with the four props in App.js, which would then set the values of that array listData
to be those four numbers, which I could then call in other files as import listData from './listData'
and reference each value as listData[1]
, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…