UNPKG

streamlit-component-lib-react-hooks

Version:

An npm package that provides support code for creating [Streamlit Components](https://docs.streamlit.io/en/stable/streamlit_components.html) with React and React Hooks.

18 lines (17 loc) 719 B
import { jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from "react"; import { Streamlit } from "streamlit-component-lib"; import { useNullableRenderData } from "../useNullableRenderData"; import ErrorBoundary from "../ErrorBoundary"; import { renderDataContext } from "./useRenderData"; export function StreamlitProvider(props) { const renderData = useNullableRenderData(); useEffect(() => { Streamlit.setFrameHeight(); }); // Don't render until we've gotten our first data from Streamlit. if (renderData == null) { return null; } return (_jsx(ErrorBoundary, { children: _jsx(renderDataContext.Provider, { value: renderData, children: props.children }) })); }