You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instantiate a cache and pass it into any rendering method as a second argument. Wherever you would use ReactDOM.renderToString, use ReactCC.renderToString.
13
18
```javascript
14
19
constReactCC=require("reactcc");
20
+
constcache=ReactCC.ComponentCache();
21
+
ReactCC.renderToString(<App />, cache>)
15
22
16
23
// ...
17
24
```
18
25
19
26
### In React app:
20
-
To cache a component, simply add a 'cache' property to it. To create a cache template, add both 'cache' and 'templatized'.
27
+
To flag a component for caching, simply add a 'cache' property to it. To create a cache template, add both 'cache' and 'templatized', along with an array of props to templatize.
21
28
22
29
```javascript
23
30
exportdefaultclassAppextendsComponent {
@@ -75,14 +82,13 @@ Insert description and implementation here
75
82
76
83
## API
77
84
78
-
### `ReactCC`
85
+
### ReactCC
79
86
ReactCC gives you access to all four of React 16's server-side rendering methods, as well as additional functionality. ReactCC methods are described below.
80
87
81
-
### `ComponentCache`
88
+
### ComponentCache
82
89
-`size`: (Optional) An integer representing the maximum size (in characters) of the cache. Defaults to 1 million.
83
90
84
91
**Example:**
85
-
86
92
```javascript
87
93
constcache=newReactCC.ComponentCache();
88
94
```
@@ -93,7 +99,6 @@ const cache = new ReactCC.ComponentCache();
93
99
-`memLife`: (Only if using Memcached) A number representing the lifetime (in seconds) of each Memcached entry. Defaults to 0.
0 commit comments