UNPKG

@livestd/react-render-counter

Version:
17 lines (16 loc) 432 B
import React, { useState } from 'react'; class CounterState { constructor(initialValue = 0) { this.initialValue = initialValue; this.count = initialValue; } inc() { this.count = this.count + 1; } } const Counter = () => { const [counter,] = useState(new CounterState()); counter.inc(); return (React.createElement(React.Fragment, null, counter.count)); }; export default Counter;