Packages

React inside Phoenix LiveView — async code splitting, client-side props diffing, and zero-config component discovery.

Retired package: Release invalid - Not production-ready, LiveView 1.0.x compatibility issue

Current section

Files

Jump to
react_phx assets dist context.js
Raw

assets/dist/context.js

import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext } from "react";
export const ReactPhxContext = createContext(null);
export function ReactPhxProvider({ children, ...props }) {
return (_jsx(ReactPhxContext.Provider, { value: props, children: children }));
}
export function useLiveReact() {
const ctx = useContext(ReactPhxContext);
if (!ctx) {
throw new Error("useLiveReact must be used within a ReactPhxProvider");
}
return ctx;
}