@@ -2193,7 +2193,7 @@ declare module Immutable {
2193
2193
* ```js
2194
2194
* const { Record } = require('immutable')
2195
2195
* const ABRecord = Record({ a: 1, b: 2 })
2196
- * const myRecord = new ABRecord({ b: 3 })
2196
+ * const myRecord = ABRecord({ b: 3 })
2197
2197
* ```
2198
2198
*
2199
2199
* Records always have a value for the keys they define. `remove`ing a key
@@ -2214,7 +2214,7 @@ declare module Immutable {
2214
2214
* ignored for this record.
2215
2215
*
2216
2216
* ```js
2217
- * const myRecord = new ABRecord({ b: 3, x: 10 })
2217
+ * const myRecord = ABRecord({ b: 3, x: 10 })
2218
2218
* myRecord.get('x') // undefined
2219
2219
* ```
2220
2220
*
@@ -2233,14 +2233,22 @@ declare module Immutable {
2233
2233
* Record. This is not a common pattern in functional environments, but is in
2234
2234
* many JS programs.
2235
2235
*
2236
+ * However Record Classes are more restricted than typical JavaScript classes.
2237
+ * They do not use a class constructor, which also means they cannot use
2238
+ * class properties (since those are technically part of a constructor).
2239
+ *
2240
+ * It's useful to think of Record Classes more like a Record Factory where
2241
+ * record instances returned from the factory have additional API methods. It
2242
+ * is best practice to not use `new` when creating new Records.
2243
+ *
2236
2244
* ```
2237
2245
* class ABRecord extends Record({ a: 1, b: 2 }) {
2238
2246
* getAB() {
2239
2247
* return this.a + this.b;
2240
2248
* }
2241
2249
* }
2242
2250
*
2243
- * var myRecord = new ABRecord({b: 3})
2251
+ * var myRecord = ABRecord({b: 3})
2244
2252
* myRecord.getAB() // 4
2245
2253
* ```
2246
2254
*
0 commit comments