React Lookup - Access the DataSource

Regardless of the data source you use, the Lookup always wraps it in a DataSource. Call the getDataSource() method to get the instance of the DataSource.

  • import React from 'react';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { Lookup } from 'devextreme-react/lookup';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.lookupRef = React.createRef();
  •  
  • this.getDataSource = this.getDataSource.bind(this);
  • }
  •  
  • getDataSource() {
  • this.ds = this.lookupRef.current.instance().getDataSource();
  • }
  •  
  • render() {
  • return (
  • <Lookup ...
  • ref={this.lookupRef}
  • />
  • );
  • }
  • }
  •  
  • export default App;

Now, you can call any method the DataSource exposes. For example, you can reload data using the reload() method.

JavaScript
  • lookupDataSource.reload();
See Also