39 | {keys.map((key) =>
40 | shouldUseMemo ? (
41 |
42 | ) : (
43 |
44 | )
45 | )}
46 |
47 | );
48 | };
49 |
--------------------------------------------------------------------------------
/src/examples/MemoDemo/ComponentC.tsx:
--------------------------------------------------------------------------------
1 | import { ReactElement, useContext } from "react";
2 | import { commonStyle } from "utils/common-styles";
3 | import { ComponentD } from "./ComponentD";
4 | import { MemoContext } from "./MemoContext";
5 |
6 | const buttonStyle = {
7 | padding: 16,
8 | minWidth: 100,
9 | width: "fit-content",
10 | cursor: "pointer",
11 | marginBottom: 24,
12 | fontSize: 16,
13 | fontWeight: "bold",
14 | };
15 |
16 | export const ComponentC = (): ReactElement => {
17 | const {
18 | showRendered,
19 | state: { c },
20 | setState,
21 | toggleShowRendered,
22 | } = useContext(MemoContext);
23 |
24 | return (
25 |
29 |
30 | Component C (context)
31 |
32 |
33 |
39 |
45 |
46 |
47 |
48 | );
49 | };
50 |
--------------------------------------------------------------------------------
/src/examples/MessagingDemo/VanillaMessagingContext.tsx:
--------------------------------------------------------------------------------
1 | import { Conversation } from "examples/MessagingDemo/FakeMessenger";
2 | import { MessageInfo, User } from "examples/MessagingDemo/types";
3 | import { createContext, ReactElement, ReactNode, useCallback, useState } from "react";
4 |
5 | interface SetState