I created a helper routeData
to map the data and pass the data to the child component <MyComponent />
:
const routeData = {
routeOne: {
title: 'Title one',
description: 'Description one',
image: '/Header.jpg',
style: config.style,
id: '01',
},
routeTwo: {
title: 'Title two',
description: 'Description two',
image: '/Header02.jpg',
style: config.style02,
id: '02',
},
};
However now I have to add all this props like:
<Route
path={routeData.routeOne.path}
render={() => (
<MyComponent
title={routeData.routeOne.title}
description={routeData.routeOne.description}
imageUrl={routeData.routeOne.image}
link={routeData.routeOne.link}
id={routeData.routeOne.id}
// etc
/>
)}
/>
Is there a better way to construct this helper and pass everything by one prop e.g.:
<Route path={routeData.routeOne.path} render={() => (
<MyComponent data={routeData.routeOne} /> )}
/>