-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
This project lacks some tests to verify the functionality.
Do you have any plans to add tests or would accept a PR?
Case in point:
export const setCustomText = customProps => {
const TextRender = Text.render
const initialDefaultProps = Text.defaultProps
Text.defaultProps = {
...initialDefaultProps,
...customProps
}
Text.render = function render(props) {
let oldProps = props
props = { ...props, style: [customProps.style, props.style] }
try {
return TextRender.apply(this, arguments)
} finally {
props = oldProps
}
}
}This code can not work. It calls TextRender.apply with the original arguments, it assigns new props ignoring the Text.defaultProps.style and then assigns the props back in the finally block to no effect.
Tests would discover this faulty behaviour.
A working version of the above code seems to be:
const setCustomText = (customProps) => {
Text.defaultProps = {
...Text.defaultProps,
...customProps,
}
const orgRender = Text.render
Text.render = function render(props:TextProps, ref:Ref<Text>) {
const style = Array.isArray(props.style) ? props.style : [props.style]
props = {
...props,
style: [Text.defaultProps.style, ...style],
}
return orgRender.call(this, props, ref)
}
}dan-lee
Metadata
Metadata
Assignees
Labels
No labels