Updated the Trace component to stateless (function instead of class)
7 years ago
ReactJS
JavaScript
I am updating the Trace component to become a simple stateless component. The changes are very small. I change it to function instead of class. So there is no constructor and the props are called directly on rendering it. Here is it:
function Trace(props){
return (
<pre>
<code>
{JSON.stringify(props.value, null, props.tabSize||2)}
</code>
</pre>
)
}
The way to use it is still the same:
<Trace value={this.state} />
I created a codepen page to experiment with it here, https://codepen.io/mjunaidi/pen/XeXrbX.
Thanks for reading!