Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { useState, useEffect, useRef} from 'react'
- import {Card} from 'antd'
- function Counter() {
- const [count, setCount]=useState(0);
- useEffect(()=>{
- prevCountRef.current=count;
- })
- const prevCount=prevCountRef.current;
- return <Card> Now: {count}, before {prevCount}</Card>;
- }
- export default Counter;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement