File tree Expand file tree Collapse file tree 3 files changed +4
-8
lines changed Expand file tree Collapse file tree 3 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { ErrorMessages } from 'validatorjs';
3
3
4
4
import { getMask , IMaskFunction } from '../mask' ;
5
5
import { validate } from '../validator' ;
6
- import { FieldValidation , IFieldValidationContext } from '../validator/context' ;
7
6
import CustomMessage from './CustomMessage' ;
8
7
9
8
export interface IStateFieldBase {
@@ -27,9 +26,6 @@ export default abstract class FieldCoreBase<
27
26
P extends IPropsFieldBase = IPropsFieldBase ,
28
27
S extends IStateFieldBase = IStateFieldBase
29
28
> extends React . PureComponent < P , S > {
30
- static contextType = FieldValidation ;
31
- context : IFieldValidationContext ;
32
-
33
29
constructor ( props : any ) {
34
30
super ( props ) ;
35
31
this . state = { showError : false , errorMessage : null } as S ;
@@ -84,10 +80,6 @@ export default abstract class FieldCoreBase<
84
80
} ;
85
81
}
86
82
87
- public componentWillUnmount ( ) {
88
- this . context && this . context . unregister ( this ) ;
89
- }
90
-
91
83
public setFormSubmitted = ( submitted : boolean ) => {
92
84
this . setState ( { submitted } ) ;
93
85
}
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import FieldCoreBase from './FieldCoreBase';
6
6
export default class ValidationContext extends React . PureComponent < { } > {
7
7
public fields : FieldCoreBase < any , any > [ ] = [ ] ;
8
8
private registerFields : IFieldValidationContext = {
9
+ getFields : ( ) => {
10
+ return this . fields ;
11
+ } ,
9
12
register : field => {
10
13
this . fields . push ( field ) ;
11
14
} ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as React from 'react';
3
3
import FieldCoreBase from '../components/FieldCoreBase' ;
4
4
5
5
export interface IFieldValidationContext {
6
+ getFields : ( ) => FieldCoreBase [ ] ;
6
7
register : ( field : FieldCoreBase ) => void ;
7
8
unregister : ( field : FieldCoreBase ) => void ;
8
9
}
You can’t perform that action at this time.
0 commit comments