Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.66 无效 #26

Open
whhlulu opened this issue Dec 16, 2021 · 1 comment
Open

0.66 无效 #26

whhlulu opened this issue Dec 16, 2021 · 1 comment

Comments

@whhlulu
Copy link

whhlulu commented Dec 16, 2021

新版本写法

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
}
}
}

@dioi2000
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants