As someone new to reactjs, I'm trying to figure out how to handle an array of objects so that it can be global and accessed from multiple components. Should I create another class and import it for this purpose?
In Angular, I would typically create a service to contain such an array in order to access it from all components.
carts = [
{
title: 'Travel',
backgroundColor: '#796157',
description: 'Keep your eyes fresh & travel to other countries.',
image: hs1,
gallery: [
'/assets/images/capture_1_travel/4.jpg',
'/assets/images/capture_1_travel/2.jpg',
'/assets/images/capture_1_travel/3.PNG'
]
},
{
title: 'Record',
backgroundColor: '#8693A2',
description: 'Record the most important moments.',
image: hs2,
gallery: [
'/assets/images/capture_3_record/2.jpg',
'/assets/images/capture_3_record/5.jpg',
'/assets/images/capture_3_record/3.jpg',
'/assets/images/capture_3_record/4.jpg',
'/assets/images/capture_3_record/6.jpg'
]
},
...