MCPcopy
hub / github.com/facebook/react / Counter

Function Counter

packages/react-reconciler/src/__tests__/useEffectEvent-test.js:146–163  ·  view source on GitHub ↗
({incrementBy})

Source from the content-addressed store, hash-verified

144 }
145
146 function Counter({incrementBy}) {
147 const [count, updateCount] = useState(0);
148 const onClick = useEffectEvent(() => updateCount(c => c + incrementBy));
149 const onMouseEnter = useEffectEvent(() => {
150 updateCount(c => c * incrementBy);
151 });
152
153 return (
154 <>
155 <IncrementButton
156 onClick={() => onClick()}
157 onMouseEnter={() => onMouseEnter()}
158 ref={button}
159 />
160 <Text text={'Count: ' + count} />
161 </>
162 );
163 }
164
165 const button = React.createRef(null);
166 ReactNoop.render(<Counter incrementBy={5} />);

Callers

nothing calls this directly

Calls 6

useInsertionEffectFunction · 0.90
useStateFunction · 0.50
useEffectEventFunction · 0.50
incrementFunction · 0.50
useEffectFunction · 0.50
onClickFunction · 0.50

Tested by

no test coverage detected