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
React Js Q7 Observe the custom hook used to get/set the address of the user. Anu called the useToManageAddress custom hook from P
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am