Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
const COLUMNS = [
  {
    title: 'GROUP ID',
    dataIndex: 'groupId',
    key: 'groupId',
    rowKey: 'groupId',
    default: true,
    sorter: (a, b) => a.groupId - b.groupId,
  },
  {
    title: 'ADMIN ID',
    dataIndex: 'adminId',
    key: 'adminId',
  },
  {
    title: 'ADMIN NAME',
    dataIndex: 'adminName',
    key: 'adminName',
    sorter: (a, b) => { return a.adminName.localeCompare(b.adminName) },
  },
  {
    title: 'GROUP TYPE',
    dataIndex: 'type',
    key: 'type',
    default: true,
    sorter: (a, b) => a.type - b.type,
    render: (rowData) => {
      return (<div>{rowData === 2 ? 'Resident' : 'Physician'}</div>)
    }
  },
  {
    title: 'DIRECTOR NAME',
    dataIndex: 'directorName',
    key: 'directorName',
  },
  {
    title: 'FAX',
    dataIndex: 'fax',
    key: 'fax',
  },
  {
    title: 'EMAIL',
    dataIndex: 'email',
    key: 'email',
    default: true
  }
]

I am trying to store this array in a redux store,
It is getting saved but with an error on console like,

JavaScript
Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'BroadcastChannel': function sorter(a, b) {
    return a.groupId - b.groupId;
  } could not be cloned.


It's getting stored in redux but without the "sorter" and "render" keys.

What I have tried:

what i thought is to convert the "render" and "sorter" key in to a string and using
JavaScript
var fn = window[function_as_string];
i can evaluate.
but problem is that i am using ES6 and i dont wann gave any function name. Please suggest a best approch to do so..

Thank you!!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900