I am in the process of creating a tester page that allows users to interact with a library component and document how it is being used.
Here is the library component:
render = () => {
let component = (
<Slider
onSlide={this.handleSlide}
totalCount={120}
/>
);
return (
<div>
<h2>Testing the Slider Component:</h2>
{component}
<code>HOW DO I DISPLAY THE COMPONENT CODE HERE?</code>
</div>
);
};
The goal is to showcase how the component functions and include the code used for testing at the end.
Is there a method to display the component code on screen without having to duplicate it within the <code>
tag?
Are there any existing npm libraries or tools that can assist with this task?