@livestd/react-render-counter
Version:
simple render counter with react hook
17 lines (16 loc) • 432 B
JavaScript
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;