UNPKG

react-native-filament

Version:

A real-time physically based 3D rendering engine for React Native

40 lines (38 loc) 1.15 kB
"use strict"; import React, { useCallback } from 'react'; import { RenderCallbackContext } from './RenderCallbackContext'; import { FilamentView } from './FilamentView'; import { StyleSheet } from 'react-native'; import { jsx as _jsx } from "react/jsx-runtime"; /** * This is the component actually exposed to the user. It wraps the `FilamentView` and adds the renderCallbacks. * @private */ export function FilamentViewWithRenderCallbacks({ children, renderCallback: renderCallbackProp, ...forwardProps }) { const renderCallbacks = RenderCallbackContext.useRenderCallbacks(); const renderCallback = useCallback(frameInfo => { 'worklet'; renderCallbackProp?.(frameInfo); renderCallbacks.value.forEach(({ callback }) => { callback(frameInfo); }); }, [renderCallbackProp, renderCallbacks]); return /*#__PURE__*/_jsx(FilamentView, { renderCallback: renderCallback, ...forwardProps, style: [styles.container, forwardProps.style], children: children }); } const styles = StyleSheet.create({ container: { flex: 1 } }); //# sourceMappingURL=FilamentViewWithRenderCallbacks.js.map