Skip to content

Commit 82fbdca

Browse files
committed
README async update
1 parent 9a0f603 commit 82fbdca

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ Instantiate a cache and pass it to any rendering method (`renderToString`, `rend
1919
**Note: All of these methods are asynchronous, and return a promise. To use them, `await` the response before rendering**
2020
```javascript
2121
const ReactCC = require("react-component-caching");
22-
const cache = ReactCC.ComponentCache();
23-
ReactCC.renderToString(<App />, cache>)
22+
const cache = new ReactCC.ComponentCache();
23+
24+
app.get('/example', async (req,res) => {
25+
const renderString = await ReactCC.renderToString(<App />, cache);
26+
res.send(renderString);
27+
});
2428

2529
// ...
2630
```
@@ -54,7 +58,12 @@ export default class App extends Component {
5458
<div>
5559
<ComponentNotToBeCached />
5660
<ComponentToCache cache />
57-
<ComponentToTemplatize templatizedProp1="value" templatizedProp2="value2" nonTemplatizedProp="anotherValue" cache templatized={["templatizedProp1", "templatizedProp2"]} />
61+
<ComponentToTemplatize
62+
templatizedProp1="value1"
63+
templatizedProp2="value2"
64+
nonTemplatizedProp="anotherValue"
65+
cache
66+
templatized={["templatizedProp1", "templatizedProp2"]} />
5867
</div>
5968
);
6069
}
@@ -69,32 +78,25 @@ React Component Caching provides its own cache implementation as well as support
6978

7079
```javascript
7180
const ReactCC = require("react-component-caching");
72-
73-
const cache = ReactCC.ComponentCache();
74-
75-
ReactCC.renderToString(<App />, cache);
81+
const cache = new ReactCC.ComponentCache();
7682
```
7783

7884
**Redis Example:**
7985

8086
```javascript
8187
const ReactCC = require("react-component-caching");
8288
const redis = require("redis");
83-
8489
const cache = redis.createClient();
85-
86-
ReactCC.renderToString(<App />, cache);
8790
```
8891

8992
**Memcached Example:**
9093

9194
```javascript
9295
const ReactCC = require("react-component-caching");
9396
const Memcached = require("memcached");
94-
9597
const cache = new Memcached(server location, options);
9698

97-
// Make sure to pass in the lifetime of the data (in seconds) as a number.
99+
// If using Memcached, make sure to pass in the lifetime of the data (in seconds) as a number.
98100
ReactCC.renderToString(<App />, cache, 1000);
99101
```
100102

0 commit comments

Comments
 (0)