Q7 Observe the custom hook used to get/set the address of the user. Anu called the useToManageAddress custom hook from P

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Q7 Observe the custom hook used to get/set the address of the user. Anu called the useToManageAddress custom hook from P

Post by answerhappygod »

Q7 Observe The Custom Hook Used To Get Set The Address Of The User Anu Called The Usetomanageaddress Custom Hook From P 1
Q7 Observe The Custom Hook Used To Get Set The Address Of The User Anu Called The Usetomanageaddress Custom Hook From P 1 (108.59 KiB) Viewed 71 times
React Js questions
Q7 Observe the custom hook used to get/set the address of the user. Anu called the useToManageAddress custom hook from Profile page and set the address. After that she is calling the same custom hook from Delivery page to get the address which was set from Profile page. Assume that all the required import and export statements are written. useToManageAddress.js const useToManageAddress = (addObj) => { const [address, setAddress] = useState({}); const setUserAddress = () => { setAddress(addObj); } return { address, setUserAddress }; } Profile.js const Profile = () => { const { setUserAddress } = useToManageAddress(); const setAddress = () => { setUser Address({ name: "Arjun", district: "Mangalore", state: "Karnataka" }); return <button onClick={setAddress }>Set Address</button> 6/14 } Delivery.js const Delivery = () => { const { address } = useToManageAddress(); return <div>{address.name}</div> ) } Predict the output of Delivery page. a) Prints the value ‘Arjun b) Nothing will be displayed address.name will be undefined c) Error d) None of the above is the right answer
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply