Ajackster/react-native-global-props

0.66 无效

Opened this issue · 1 comments

新版本写法

export const setCustomText = customProps => {
const TextRender = Text.render
const initialDefaultProps = Text.defaultProps
Text.defaultProps = {
...initialDefaultProps,
...customProps
}
Text.render = function render(props, ref) {
let oldProps = props
props = { ...props, style: [customProps.style, props.style] }
try {
return TextRender.apply(this, [props], ref)
} finally {
props = oldProps
}
}
}

i guess you had same problem with me
use this - https://www.npmjs.com/package/react-native-simple-default-props