Page 1 of 1

How to import ObjectUtils

Posted: 06 Jul 2021, 19:05
by liamoshea
I am following the linked example to create my own sortFunction for the DataTable:
https://github.com/primefaces/primereact/issues/348

My sortFunction is working, but I could not figure out how to import ObjectUtils from the PrimeReact library in my React application. I ended up copying and pasting the resolveFieldData and isFunction functions from ObjectUtils.js into my file as a workaround.

In the sample I see : import ObjectUtils from '../../components/utils/ObjectUtils';

I have tried :
import ObjectUtils from 'primereact/utils/Utils';
import {ObjectUtils} from 'primereact/utils/Utils'
import ObjectUtils from 'primereact/utils/ObjectUtils'

all with no luck. Is there a way to import this class into my React component?

Thanks

Re: How to import ObjectUtils

Posted: 07 Jul 2021, 09:32
by mcandu
Could you try

Code: Select all

import ObjectUtils from 'primereact/components/utils/ObjectUtils';

Re: How to import ObjectUtils

Posted: 07 Jul 2021, 15:09
by mert.sincan
Hi,

Which version are you using?

Re: How to import ObjectUtils

Posted: 13 Oct 2021, 20:27
by activedecay

Code: Select all

// to import ObjectUtils
import { ObjectUtils } from 'primeng/utils'

// to use a function from it
class SomeComponent {
  someMethod() {
    const value1 = ObjectUtils.resolveFieldData(data1, field)
  }
}

Re: How to import ObjectUtils

Posted: 19 Nov 2021, 03:04
by Melloware
Mert, I am having this same issue with 7.0.1. I can't get to ObjectUtils...

Re: How to import ObjectUtils

Posted: 27 Nov 2021, 18:48
by Melloware

Re: How to import ObjectUtils

Posted: 14 Dec 2021, 16:03
by Melloware
This is fixed in 7.1.0