mirror of
https://github.com/zhigang1992/react-native-global-props.git
synced 2026-03-26 23:24:25 +08:00
Merge pull request #14 from maieonbrix/master
convert all custom function [wip][do_not_merge_now]
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { ActivityIndicator } from 'react-native';
|
||||
import { ActivityIndicator } from 'react-native'
|
||||
|
||||
export const setCustomActivityIndicator = customProps => {
|
||||
const ActivityIndicatorRender = ActivityIndicator.prototype.render;
|
||||
const initialDefaultProps = ActivityIndicator.prototype.constructor.defaultProps;
|
||||
ActivityIndicator.prototype.constructor.defaultProps = {
|
||||
const ActivityIndicatorRender = ActivityIndicator.render
|
||||
const initialDefaultProps = ActivityIndicator.defaultProps
|
||||
ActivityIndicator.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
ActivityIndicator.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
ActivityIndicator.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return ActivityIndicatorRender.apply(this, arguments);
|
||||
return ActivityIndicatorRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
Image
|
||||
} from 'react-native';
|
||||
import { Image } from 'react-native'
|
||||
|
||||
export const setCustomImage = customProps => {
|
||||
const ImageRender = Image.prototype.render;
|
||||
const initialDefaultProps = Image.prototype.constructor.defaultProps;
|
||||
Image.prototype.constructor.defaultProps = {
|
||||
const ImageRender = Image.render
|
||||
const initialDefaultProps = Image.defaultProps
|
||||
Image.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
Image.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
Image.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return ImageRender.apply(this, arguments);
|
||||
return ImageRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { KeyboardAvoidingView } from 'react-native';
|
||||
import { KeyboardAvoidingView } from 'react-native'
|
||||
|
||||
export const setCustomKeyboardAvoidingView = customProps => {
|
||||
const KeyboardAvoidingViewRender = KeyboardAvoidingView.prototype.render;
|
||||
const initialDefaultProps = KeyboardAvoidingView.prototype.constructor.defaultProps;
|
||||
KeyboardAvoidingView.prototype.constructor.defaultProps = {
|
||||
const KeyboardAvoidingViewRender = KeyboardAvoidingView.render
|
||||
const initialDefaultProps = KeyboardAvoidingView.defaultProps
|
||||
KeyboardAvoidingView.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
KeyboardAvoidingView.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
KeyboardAvoidingView.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return KeyboardAvoidingViewRender.apply(this, arguments);
|
||||
return KeyboardAvoidingViewRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
ListView
|
||||
} from 'react-native';
|
||||
import { ListView } from 'react-native'
|
||||
|
||||
export const setCustomListView = customProps => {
|
||||
const ListViewRender = ListView.prototype.render;
|
||||
const initialDefaultProps = ListView.prototype.constructor.defaultProps;
|
||||
ListView.prototype.constructor.defaultProps = {
|
||||
const ListViewRender = ListView.render
|
||||
const initialDefaultProps = ListView.defaultProps
|
||||
ListView.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
ListView.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
ListView.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return ListViewRender.apply(this, arguments);
|
||||
return ListViewRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
Modal
|
||||
} from 'react-native';
|
||||
import { Modal } from 'react-native'
|
||||
|
||||
export const setCustomModal = customProps => {
|
||||
const ModalRender = Modal.prototype.render;
|
||||
const initialDefaultProps = Modal.prototype.constructor.defaultProps;
|
||||
Modal.prototype.constructor.defaultProps = {
|
||||
const ModalRender = Modal.render
|
||||
const initialDefaultProps = Modal.defaultProps
|
||||
Modal.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
Modal.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
Modal.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return ModalRender.apply(this, arguments);
|
||||
return ModalRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
Picker
|
||||
} from 'react-native';
|
||||
import { Picker } from 'react-native'
|
||||
|
||||
export const setCustomPicker = customProps => {
|
||||
const PickerRender = Picker.prototype.render;
|
||||
const initialDefaultProps = Picker.prototype.constructor.defaultProps;
|
||||
Picker.prototype.constructor.defaultProps = {
|
||||
const PickerRender = Picker.render
|
||||
const initialDefaultProps = Picker.defaultProps
|
||||
Picker.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
Picker.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
Picker.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return PickerRender.apply(this, arguments);
|
||||
return PickerRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
RefreshControl
|
||||
} from 'react-native';
|
||||
import { RefreshControl } from 'react-native'
|
||||
|
||||
export const setCustomRefreshControl = customProps => {
|
||||
const RefreshControlRender = RefreshControl.prototype.render;
|
||||
const initialDefaultProps = RefreshControl.prototype.constructor.defaultProps;
|
||||
RefreshControl.prototype.constructor.defaultProps = {
|
||||
const RefreshControlRender = RefreshControl.render
|
||||
const initialDefaultProps = RefreshControl.defaultProps
|
||||
RefreshControl.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
RefreshControl.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
RefreshControl.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return RefreshControlRender.apply(this, arguments);
|
||||
return RefreshControlRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
ScrollView
|
||||
} from 'react-native';
|
||||
import { ScrollView } from 'react-native'
|
||||
|
||||
export const setCustomScrollView = customProps => {
|
||||
const ScrollViewRender = ScrollView.prototype.render;
|
||||
const initialDefaultProps = ScrollView.prototype.constructor.defaultProps;
|
||||
ScrollView.prototype.constructor.defaultProps = {
|
||||
const ScrollViewRender = ScrollView.render
|
||||
const initialDefaultProps = ScrollView.defaultProps
|
||||
ScrollView.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
ScrollView.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
ScrollView.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return ScrollViewRender.apply(this, arguments);
|
||||
return ScrollViewRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
Slider
|
||||
} from 'react-native';
|
||||
import { Slider } from 'react-native'
|
||||
|
||||
export const setCustomSlider = customProps => {
|
||||
const SliderRender = Slider.prototype.render;
|
||||
const initialDefaultProps = Slider.prototype.constructor.defaultProps;
|
||||
Slider.prototype.constructor.defaultProps = {
|
||||
const SliderRender = Slider.render
|
||||
const initialDefaultProps = Slider.defaultProps
|
||||
Slider.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
Slider.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
Slider.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return SliderRender.apply(this, arguments);
|
||||
return SliderRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
StatusBar
|
||||
} from 'react-native';
|
||||
import { StatusBar } from 'react-native'
|
||||
|
||||
export const setCustomStatusBar = customProps => {
|
||||
const StatusBarRender = StatusBar.prototype.render;
|
||||
const initialDefaultProps = StatusBar.prototype.constructor.defaultProps;
|
||||
StatusBar.prototype.constructor.defaultProps = {
|
||||
const StatusBarRender = StatusBar.render
|
||||
const initialDefaultProps = StatusBar.defaultProps
|
||||
StatusBar.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
StatusBar.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
StatusBar.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return StatusBarRender.apply(this, arguments);
|
||||
return StatusBarRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
Switch
|
||||
} from 'react-native';
|
||||
import { Switch } from 'react-native'
|
||||
|
||||
export const setCustomSwitch = customProps => {
|
||||
const SwitchRender = Switch.prototype.render;
|
||||
const initialDefaultProps = Switch.prototype.constructor.defaultProps;
|
||||
Switch.prototype.constructor.defaultProps = {
|
||||
const SwitchRender = Switch.render
|
||||
const initialDefaultProps = Switch.defaultProps
|
||||
Switch.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
Switch.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
Switch.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return SwitchRender.apply(this, arguments);
|
||||
return SwitchRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
Text,
|
||||
} from 'react-native';
|
||||
import { Text } from 'react-native'
|
||||
|
||||
export const setCustomText = customProps => {
|
||||
const TextRender = Text.prototype.render;
|
||||
const initialDefaultProps = Text.prototype.constructor.defaultProps;
|
||||
Text.prototype.constructor.defaultProps = {
|
||||
const TextRender = Text.render
|
||||
const initialDefaultProps = Text.defaultProps
|
||||
Text.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
Text.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
Text.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return TextRender.apply(this, arguments);
|
||||
return TextRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import {
|
||||
TextInput
|
||||
} from 'react-native';
|
||||
import { TextInput } from 'react-native'
|
||||
|
||||
export const setCustomTextInput = customProps => {
|
||||
const TextInputRender = TextInput.prototype.render;
|
||||
const initialDefaultProps = TextInput.prototype.constructor.defaultProps;
|
||||
TextInput.prototype.constructor.defaultProps = {
|
||||
const TextInputRender = TextInput.render
|
||||
const initialDefaultProps = TextInput.defaultProps
|
||||
TextInput.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
TextInput.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
TextInput.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return TextInputRender.apply(this, arguments);
|
||||
return TextInputRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,74 +5,71 @@ import {
|
||||
TouchableOpacity
|
||||
} from 'react-native';
|
||||
|
||||
export const setCustomTouchableHighlight = customProps => {
|
||||
const TouchableHighlightRender = TouchableHighlight.prototype.render;
|
||||
const initialDefaultProps = TouchableHighlight.prototype.constructor.defaultProps;
|
||||
TouchableHighlight.prototype.constructor.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
}
|
||||
TouchableHighlight.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
try {
|
||||
return TouchableHighlightRender.apply(this, arguments);
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const setCustomTouchableNativeFeedback = customProps => {
|
||||
const TouchableNativeFeedbackRender = TouchableNativeFeedback.prototype.render;
|
||||
const initialDefaultProps = TouchableNativeFeedback.prototype.constructor.defaultProps;
|
||||
TouchableNativeFeedback.prototype.constructor.defaultProps = {
|
||||
const TouchableNativeFeedbackRender = TouchableNativeFeedback.render
|
||||
const initialDefaultProps = TouchableNativeFeedback.defaultProps
|
||||
TouchableNativeFeedback.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
TouchableNativeFeedback.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
TouchableNativeFeedback.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return TouchableNativeFeedbackRender.apply(this, arguments);
|
||||
return TouchableNativeFeedbackRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
export const setCustomTouchableWithoutFeedback = customProps => {
|
||||
const TouchableWithoutFeedbackRender = TouchableWithoutFeedback.prototype.render;
|
||||
const initialDefaultProps = TouchableWithoutFeedback.prototype.constructor.defaultProps;
|
||||
TouchableWithoutFeedback.prototype.constructor.defaultProps = {
|
||||
const TouchableWithoutFeedbackRender = TouchableWithoutFeedback.render
|
||||
const initialDefaultProps = TouchableWithoutFeedback.defaultProps
|
||||
TouchableWithoutFeedback.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
TouchableWithoutFeedback.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
TouchableWithoutFeedback.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return TouchableWithoutFeedbackRender.apply(this, arguments);
|
||||
return TouchableWithoutFeedbackRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
export const setCustomTouchableOpacity = customProps => {
|
||||
const TouchableOpacityRender = TouchableOpacity.prototype.render;
|
||||
const initialDefaultProps = TouchableOpacity.prototype.constructor.defaultProps;
|
||||
TouchableOpacity.prototype.constructor.defaultProps = {
|
||||
const TouchableOpacityRender = TouchableOpacity.render
|
||||
const initialDefaultProps = TouchableOpacity.defaultProps
|
||||
TouchableOpacity.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
TouchableOpacity.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
TouchableOpacity.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return TouchableOpacityRender.apply(this, arguments);
|
||||
return TouchableOpacityRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
export const setCustomTouchableHighlight = customProps => {
|
||||
const TouchableHighlightRender = TouchableHighlight.render
|
||||
const initialDefaultProps = TouchableHighlight.defaultProps
|
||||
TouchableHighlight.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps
|
||||
}
|
||||
TouchableHighlight.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return TouchableHighlightRender.apply(this, arguments)
|
||||
} finally {
|
||||
props = oldProps
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@ import {
|
||||
} from 'react-native';
|
||||
|
||||
export const setCustomView = customProps => {
|
||||
const ViewRender = View.prototype.render;
|
||||
const initialDefaultProps = View.prototype.constructor.defaultProps;
|
||||
View.prototype.constructor.defaultProps = {
|
||||
const ViewRender = View.render
|
||||
const initialDefaultProps = View.defaultProps
|
||||
View.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
View.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
View.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return ViewRender.apply(this, arguments);
|
||||
return ViewRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@ import {
|
||||
} from 'react-native';
|
||||
|
||||
export const setCustomWebView = customProps => {
|
||||
const WebViewRender = WebView.prototype.render;
|
||||
const initialDefaultProps = WebView.prototype.constructor.defaultProps;
|
||||
WebView.prototype.constructor.defaultProps = {
|
||||
const WebViewRender = WebView.render
|
||||
const initialDefaultProps = WebView.defaultProps
|
||||
WebView.defaultProps = {
|
||||
...initialDefaultProps,
|
||||
...customProps,
|
||||
...customProps
|
||||
}
|
||||
WebView.prototype.render = function render() {
|
||||
let oldProps = this.props;
|
||||
this.props = { ...this.props, style: [customProps.style, this.props.style] };
|
||||
WebView.render = function render(props) {
|
||||
let oldProps = props
|
||||
props = { ...props, style: [customProps.style, props.style] }
|
||||
try {
|
||||
return WebViewRender.apply(this, arguments);
|
||||
return WebViewRender.apply(this, arguments)
|
||||
} finally {
|
||||
this.props = oldProps;
|
||||
props = oldProps
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user