Commit 505db59 1 parent 8c9ab06 commit 505db59 Copy full SHA for 505db59
File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ const ArrayBaseContext = createContext<IArrayBaseContext>(null)
74
74
75
75
const ItemContext = createContext < IArrayBaseItemProps > ( null )
76
76
77
+ const takeRecord = ( val : any ) => ( typeof val === 'function' ? val ( ) : val )
78
+
77
79
const useArray = ( ) => {
78
80
return useContext ( ArrayBaseContext )
79
81
}
@@ -85,7 +87,7 @@ const useIndex = (index?: number) => {
85
87
86
88
const useRecord = ( record ?: number ) => {
87
89
const ctx = useContext ( ItemContext )
88
- return ctx ? ctx . record : record
90
+ return takeRecord ( ctx ? ctx . record : record )
89
91
}
90
92
91
93
const getSchemaDefaultValue = ( schema : Schema ) => {
@@ -123,9 +125,7 @@ ArrayBase.Item = ({ children, ...props }) => {
123
125
< ItemContext . Provider value = { props } >
124
126
< RecordScope
125
127
getIndex = { ( ) => props . index }
126
- getRecord = { ( ) =>
127
- typeof props . record === 'function' ? props . record ( ) : props . record
128
- }
128
+ getRecord = { ( ) => takeRecord ( props . record ) }
129
129
>
130
130
{ children }
131
131
</ RecordScope >
Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ const ArrayBaseContext = createContext<IArrayBaseContext>(null)
70
70
71
71
const ItemContext = createContext < IArrayBaseItemProps > ( null )
72
72
73
+ const takeRecord = ( val : any ) => ( typeof val === 'function' ? val ( ) : val )
74
+
73
75
const useArray = ( ) => {
74
76
return useContext ( ArrayBaseContext )
75
77
}
@@ -81,7 +83,7 @@ const useIndex = (index?: number) => {
81
83
82
84
const useRecord = ( record ?: number ) => {
83
85
const ctx = useContext ( ItemContext )
84
- return ctx ? ctx . record : record
86
+ return takeRecord ( ctx ? ctx . record : record )
85
87
}
86
88
87
89
const getSchemaDefaultValue = ( schema : Schema ) => {
@@ -119,9 +121,7 @@ ArrayBase.Item = ({ children, ...props }) => {
119
121
< ItemContext . Provider value = { props } >
120
122
< RecordScope
121
123
getIndex = { ( ) => props . index }
122
- getRecord = { ( ) =>
123
- typeof props . record === 'function' ? props . record ( ) : props . record
124
- }
124
+ getRecord = { ( ) => takeRecord ( props . record ) }
125
125
>
126
126
{ children }
127
127
</ RecordScope >
You can’t perform that action at this time.
0 commit comments