React RadioGroup - Handle the Value Change Event

To process a new RadioGroup value, you need to handle the value change event. If the handling function is not going to be changed during the lifetime of the UI component, assign it to the onValueChanged property when you configure the UI component.

  • import React from 'react';
  • import 'devextreme/dist/css/dx.light.css';
  •  
  • import { RadioGroup } from 'devextreme-react/radio-group';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.dataSource = ["Low", "Normal", "Urgent", "High"];
  • this.state = {
  • value: this.dataSource[1]
  • };
  • this.handleValueChange = this.handleValueChange.bind(this);
  • }
  •  
  • handleValueChange(e) {
  • const previousValue = e.previousValue;
  • const newValue = e.value;
  • // Event handling commands go here
  •  
  • this.setState({
  • value: newValue
  • });
  • }
  •  
  • render() {
  • return (
  • <RadioGroup
  • dataSource={this.dataSource}
  • value={this.state.value}
  • onValueChanged={this.handleValueChange}
  • />
  • );
  • }
  • }
  •  
  • export default App;
See Also