I'm using an array to populate a settings page and some of the buttons have functions attached.
Here's what I want to do. In one file export an array with objects that refer to functions within the same file OR export a class, then access the array from within that class, referring to functions inside the class.
// import file
import Settings from './Settings';
console.log(Settings.settingsArray);
// export file
export const settingsArray = [
{
title: " ",
data: [
{
title: "Export data",
func: this.exportData
}
]
},
{
title: " ",
data: [
{
title: "Set custom code",
func: this.showDialog
},
]
}
]
exportData = () => {
// some code
};
showDialog = () => {
// some code
};
thisdoesn't refer to anything useful in this scope.exportDatashould already exist in order to be referred in an array. It should be referred withoutthis.