Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created December 7, 2021 08:12
Show Gist options
  • Select an option

  • Save hieptl/b5e922aa31673ddf3f7d0ebcb69364a6 to your computer and use it in GitHub Desktop.

Select an option

Save hieptl/b5e922aa31673ddf3f7d0ebcb69364a6 to your computer and use it in GitHub Desktop.
home.js - Zocdoc Clone
import React, { useContext } from 'react';
import Doctors from './Doctors';
import Appointments from './Appointments';
import Context from '../context';
const Home = (props) => {
const { navigation } = props;
const { user } = useContext(Context);
const renderBody = () => {
if (user.role === 'Patient') {
return <Doctors navigation={navigation} />;
} else if (user.role === 'Doctor') {
return <Appointments navigation={navigation} />;
}
return <></>;
}
if (!user) {
return <></>;
}
return (
<>
{renderBody()}
</>
);
};
export default Home;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment