Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Map mutates Records #268

Closed
Closed
@zgotsch

Description

@zgotsch

I noticed when using Records that using map mutates the record and returns undefined. I assumed that map would return a new record and leave the old record unmodified.

var Immutable = require("immutable");

var Person = Immutable.Record({name: "Zach", age: 25});

var me = new Person();
console.log(me.toString());
// Record { name: "Zach", age: 25 }

me.map(function(v, k) {
  if (k === "age") {
    return v + 1;
  } else {
    return v;
  }
});  // -> undefined

console.log(me.toString());
// Record { name: "Zach", age: 26 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions