Computer Science, asked by salamkarishma506, 4 days ago

Ram wants to learn how to use forms and routing in ReactJS.

Help him to create a react app where you are having navbar containing 3 links (home, about, contact) help him to create those links also take input from user in the form (HTML form) and display the data retrieved from the form on console.

(Make use of React Hooks.)

Answers

Answered by tahirmureedmultan
1

Explanation:

import React, { useState, useEffect } from 'react';

function FriendStatus(props) {

const [isOnline, setIsOnline] = useState(null);

useEffect(() => {

function handleStatusChange(status) {

setIsOnline(status.isOnline);

}

ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);

return () => {

ChatAPI.unsubscribeFromFriendStatus(props.friend.id, handleStatusChange);

};

});

if (isOnline === null) {

return 'Loading...';

}

return isOnline ? 'Online' : 'Offline';

}

Similar questions