Skip to content

Commit

Permalink
fix: RN 0.65 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cmorbitzer authored and kylerjensen committed Apr 17, 2023
1 parent 871ff0d commit 984a32f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src/utilities/overrideTextInputRenderFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ export function overrideTextInputRenderFn() {
}

overrideRenderFn(...args: any[]) {
const element = originalRenderFn.call(this, ...args);
const fontFaces = Object.values(globalFontFaces);
const originalStyle: TextStyle = StyleSheet.flatten([element.props.style]);
const overrideStyle: TextStyle = generateOverrideStyle(fontFaces, originalStyle);
const flattenedStyle: TextStyle = StyleSheet.flatten([originalStyle, overrideStyle]);
return React.cloneElement(element, { style: flattenedStyle });
if (args.length && args[0].style) {
const fontFaces = Object.values(globalFontFaces);
const originalStyle: TextStyle = StyleSheet.flatten([args[0].style]);
const overrideStyle: TextStyle = generateOverrideStyle(fontFaces, originalStyle);
const flattenedStyle: TextStyle = StyleSheet.flatten([originalStyle, overrideStyle]);
args.splice(0, 1, { ...args[0], style: flattenedStyle });
}

return originalRenderFn.call(this, ...args);
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/utilities/overrideTextRenderFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ export function overrideTextRenderFn() {
}

overrideRenderFn(...args: any[]) {
const element = originalRenderFn.call(this, ...args);
const fontFaces = Object.values(globalFontFaces);
const originalStyle: TextStyle = StyleSheet.flatten([element.props.style]);
const overrideStyle: TextStyle = generateOverrideStyle(fontFaces, originalStyle);
const flattenedStyle: TextStyle = StyleSheet.flatten([originalStyle, overrideStyle]);
return React.cloneElement(element, { style: flattenedStyle });
if (args.length && args[0].style) {
const fontFaces = Object.values(globalFontFaces);
const originalStyle: TextStyle = StyleSheet.flatten([args[0].style]);
const overrideStyle: TextStyle = generateOverrideStyle(fontFaces, originalStyle);
const flattenedStyle: TextStyle = StyleSheet.flatten([originalStyle, overrideStyle]);
args.splice(0, 1, { ...args[0], style: flattenedStyle });
}

return originalRenderFn.call(this, ...args);
}
}

Expand Down

0 comments on commit 984a32f

Please sign in to comment.