storybook/docs/snippets/react/mock-context-in-use.js.mdx
2021-02-23 00:26:03 +00:00

21 lines
436 B
Plaintext

```js
// ProfilePage.js
import { useContext } from 'react';
import ProfilePageContext from './ProfilePageContext';
const ProfilePage = ({ name, userId }) => {
const { UserPostsContainer, UserFriendsContainer } = useContext(ProfilePageContext);
return (
<div>
<h1>{name}</h1>
<UserPostsContainer userId={userId} />
<UserFriendsContainer userId={userId} />
</div>
);
};
export default ProfilePage;
```