Let's consider a plain JavaScript object, holding simple information, like a name and a parent's name. The following snippet shows how we define the person object in normal JavaScript:
import { fromJS } from 'immutable';
// Normal Javascript
const person = {
name: 'Yoshmi Mukhiya',
parents: [
{
type: "Mother",
name: "Anju Mukhiya",
},
{
type: "Father",
name: "Suresh Kumar Mukhiya"
}
]
};
const immutablePerson = fromJS(person);
We can use fromJS to convert any normal JavaScript to immutable JS.