Search code examples
javascriptreactjssingletoninstantiation

Javascript Web Components Singleton - Where to Put the Data?


I'm coding my resume and built components for the various sections and they're singletons (there is a single section for job experience, a single one for personal information, etc.).

Each of them have data that is rendered by them (e.g the JobExperience component renders data from an object containing informaiton about my previous jobs), and that data is associated with the components 1-1.

My question is: is it a good practice to put the data inside the components, or is it better to send the data to the components externally? In my case in React, it's either passing the data via props or having it as inside the component file.


Solution

  • I was advised by a professional developer to put the data inside the componentsr, following the smart somponents practice.