How to import ObjectUtils

UI Components for React
Post Reply
liamoshea
Posts: 9
Joined: 15 Jan 2021, 20:32

06 Jul 2021, 19:05

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

mcandu
Posts: 107
Joined: 20 Jan 2021, 16:31

07 Jul 2021, 09:32

Could you try

Code: Select all

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

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

07 Jul 2021, 15:09

Hi,

Which version are you using?

activedecay
Posts: 1
Joined: 01 Apr 2020, 18:17

13 Oct 2021, 20:27

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)
  }
}

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

19 Nov 2021, 03:04

Mert, I am having this same issue with 7.0.1. I can't get to ObjectUtils...
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

27 Nov 2021, 18:48

PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

14 Dec 2021, 16:03

This is fixed in 7.1.0
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: AustinduG and 7 guests