MCPcopy Index your code
hub / github.com/react/react / Page

Function Page

packages/react-reconciler/src/__tests__/useEffectEvent-test.js:807–830  ·  view source on GitHub ↗
({url})

Source from the content-addressed store, hash-verified

805 }
806
807 function Page({url}) {
808 const {items, updateItems} = useContext(ShoppingCartContext);
809 const onClick = useEffectEvent(() => updateItems([...items, 1]));
810 const numberOfItems = items.length;
811
812 const onVisit = useEffectEvent(visitedUrl => {
813 Scheduler.log(
814 'url: ' + visitedUrl + ', numberOfItems: ' + numberOfItems,
815 );
816 });
817
818 useEffect(() => {
819 onVisit(url);
820 }, [url]);
821
822 return (
823 <AddToCartButton
824 onClick={() => {
825 onClick();
826 }}
827 ref={button}
828 />
829 );
830 }
831
832 const button = React.createRef(null);
833 await act(() =>

Callers

nothing calls this directly

Calls 3

useContextFunction · 0.50
useEffectEventFunction · 0.50
useEffectFunction · 0.50

Tested by

no test coverage detected