Silly React Articles (Part 2): Constants Declaration in React for easy list rendering
Nov 13, 2023
When writing JSX in React and you’re creating an unordered list (UL) that looks something like this:
There’s a better way to write this code which is by creating a folder in the ‘src’ folder named ‘constants’ with an ‘index’ file, in there you’d declare your lists as:
Then re-render in your JSX folder as:
First, create a type as an interface then import and map your links as seen above.
Conclusion
I expect questions for clarification. Kindly criticize and make corrections as well. Share Thank you.