UNPKG

961 BTypeScriptView Raw
1import { NativeModulesProxy, requireNativeViewManager } from '@unimodules/core';
2import * as React from 'react';
3import { findNodeHandle } from 'react-native';
4
5import { BlurProps, BlurTint, ComponentOrHandle } from './BlurView.types';
6
7export default class BlurView extends React.Component<BlurProps> {
8 static defaultProps = {
9 tint: 'default' as BlurTint,
10 intensity: 50,
11 };
12
13 _root: ComponentOrHandle = null;
14
15 _setNativeRef = (ref: ComponentOrHandle) => {
16 this._root = ref;
17 };
18
19 setNativeProps = nativeProps => {
20 if (this._root) {
21 NativeModulesProxy.ExpoBlurViewManager.updateProps(nativeProps, findNodeHandle(this._root));
22 }
23 };
24
25 render() {
26 const { style, ...props } = this.props;
27 return (
28 <NativeBlurView
29 {...props}
30 ref={this._setNativeRef}
31 style={[style, { backgroundColor: 'transparent' }]}
32 />
33 );
34 }
35}
36
37const NativeBlurView = requireNativeViewManager('ExpoBlurView');