DevExtreme React - Guid Methods

This section describes methods that control a Guid instance.

ctor()

Creates a new Guid instance that contains a generated GUID.

App.js
  • // ...
  • import Guid from 'devextreme/core/guid';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.guid = new Guid();
  • }
  • }
  • export default App;

ctor(value)

Creates a new Guid instance that contains the specified GUID.

Parameters:
value:

String

A string representation of the GUID.

Hyphens in the GUID are optional:

App.js
  • // ...
  • import Guid from 'devextreme/core/guid';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.guid = new Guid("40810dcc-e08b-10a2-8227-c67c8933c31a");
  • // or
  • this.guid = new Guid("40810dcce08b10a28227c67c8933c31a");
  • }
  • }
  • export default App;

toString()

Gets the GUID. Works identically to the valueOf() method.

Return Value:

String

The GUID.

The returned GUID is always hyphened even if the Guid was created with a non-hyphened version:

App.js
  • // ...
  • import Guid from 'devextreme/core/guid';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.guid = new Guid("40810dcce08b10a28227c67c8933c31a");
  • console.log(this.guid.toString()); // logs 40810dcc-e08b-10a2-8227-c67c8933c31a
  • }
  • }
  • export default App;

valueOf()

Gets the GUID. Works identically to the toString() method.

Return Value:

String

The GUID.

The returned GUID is always hyphened even if the Guid was created with a non-hyphened version:

App.js
  • // ...
  • import Guid from 'devextreme/core/guid';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.guid = new Guid("40810dcce08b10a28227c67c8933c31a");
  • console.log(this.guid.valueOf()); // logs 40810dcc-e08b-10a2-8227-c67c8933c31a
  • }
  • }
  • export default App;