Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 5094ade

Browse files
committed
Exposing getValue in Control props
1 parent 74b196f commit 5094ade

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/components/control-component.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import omit from '../utils/omit';
1212
import actionTypes from '../action-types';
1313
import debounce from '../utils/debounce';
1414

15-
import getValue from '../utils/get-value';
15+
import _getValue from '../utils/get-value';
1616
import getValidity from '../utils/get-validity';
1717
import invertValidity from '../utils/invert-validity';
1818
import getFieldFromState from '../utils/get-field-from-state';
@@ -114,6 +114,7 @@ const propTypes = {
114114
withField: PropTypes.bool,
115115
debounce: PropTypes.number,
116116
persist: PropTypes.bool,
117+
getValue: PropTypes.func,
117118
};
118119

119120
const defaultStrategy = {
@@ -226,6 +227,7 @@ function createControlClass(s = defaultStrategy) {
226227
model,
227228
modelValue,
228229
changeAction,
230+
getValue,
229231
} = this.props;
230232
const value = this.isToggle()
231233
? getToggleValue(this.props)
@@ -284,6 +286,7 @@ function createControlClass(s = defaultStrategy) {
284286
modelValue,
285287
updateOn,
286288
dispatch,
289+
getValue,
287290
} = this.props;
288291

289292
// If there are no async validators,
@@ -423,6 +426,8 @@ function createControlClass(s = defaultStrategy) {
423426
}
424427

425428
handleChange(event) {
429+
const { getValue } = this.props;
430+
426431
if (event && event.persist) event.persist();
427432

428433
this.setViewValue(getValue(event));
@@ -433,6 +438,7 @@ function createControlClass(s = defaultStrategy) {
433438
const {
434439
controlProps: { onKeyPress },
435440
dispatch,
441+
getValue,
436442
} = this.props;
437443

438444
// Get the value from the event
@@ -498,6 +504,7 @@ function createControlClass(s = defaultStrategy) {
498504
ignore,
499505
withField,
500506
fieldValue,
507+
getValue,
501508
} = this.props;
502509

503510
const eventAction = {
@@ -640,6 +647,7 @@ function createControlClass(s = defaultStrategy) {
640647
component: 'input',
641648
withField: true,
642649
persist: false,
650+
getValue: _getValue,
643651
};
644652

645653
function mapStateToProps(state, props) {

0 commit comments

Comments
 (0)