File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 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)
7474
7575const ItemContext = createContext < IArrayBaseItemProps > ( null )
7676
77+ const takeRecord = ( val : any ) => ( typeof val === 'function' ? val ( ) : val )
78+
7779const useArray = ( ) => {
7880 return useContext ( ArrayBaseContext )
7981}
@@ -85,7 +87,7 @@ const useIndex = (index?: number) => {
8587
8688const useRecord = ( record ?: number ) => {
8789 const ctx = useContext ( ItemContext )
88- return ctx ? ctx . record : record
90+ return takeRecord ( ctx ? ctx . record : record )
8991}
9092
9193const getSchemaDefaultValue = ( schema : Schema ) => {
@@ -123,9 +125,7 @@ ArrayBase.Item = ({ children, ...props }) => {
123125 < ItemContext . Provider value = { props } >
124126 < RecordScope
125127 getIndex = { ( ) => props . index }
126- getRecord = { ( ) =>
127- typeof props . record === 'function' ? props . record ( ) : props . record
128- }
128+ getRecord = { ( ) => takeRecord ( props . record ) }
129129 >
130130 { children }
131131 </ RecordScope >
Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ const ArrayBaseContext = createContext<IArrayBaseContext>(null)
7070
7171const ItemContext = createContext < IArrayBaseItemProps > ( null )
7272
73+ const takeRecord = ( val : any ) => ( typeof val === 'function' ? val ( ) : val )
74+
7375const useArray = ( ) => {
7476 return useContext ( ArrayBaseContext )
7577}
@@ -81,7 +83,7 @@ const useIndex = (index?: number) => {
8183
8284const useRecord = ( record ?: number ) => {
8385 const ctx = useContext ( ItemContext )
84- return ctx ? ctx . record : record
86+ return takeRecord ( ctx ? ctx . record : record )
8587}
8688
8789const getSchemaDefaultValue = ( schema : Schema ) => {
@@ -119,9 +121,7 @@ ArrayBase.Item = ({ children, ...props }) => {
119121 < ItemContext . Provider value = { props } >
120122 < RecordScope
121123 getIndex = { ( ) => props . index }
122- getRecord = { ( ) =>
123- typeof props . record === 'function' ? props . record ( ) : props . record
124- }
124+ getRecord = { ( ) => takeRecord ( props . record ) }
125125 >
126126 { children }
127127 </ RecordScope >
You can’t perform that action at this time.
0 commit comments