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.
13 lines (12 loc) • 410 B
JavaScript
import React, { useContext } from "react";
export const renderDataContext = React.createContext(undefined);
/**
* Returns `RenderData` received from Streamlit.
*/
export const useRenderData = () => {
const contextValue = useContext(renderDataContext);
if (contextValue == null) {
throw new Error("useRenderData() must be used inside <StreamlitProvider />");
}
return contextValue;
};