Open Pioneer Trails Packages
    Preparing search index...

    Variable usePropertyFormContextConst

    usePropertyFormContext: () => PropertyFormContext = usePropertyFormContextImpl

    React hook for accessing the property form context.

    Provides access to the PropertyFormContext instance, which contains the current feature being edited and methods to read and update its properties. This hook must be called from within a component that is rendered inside a property form (typically in a custom form rendered by DynamicFormTemplate).

    The context also allows controlling the form's validity by setting the isValid property, which determines whether the save button is enabled.

    Type Declaration

    Error if called outside of a property form context (e.g., when no feature is being edited).

    import { useReactiveSnapshot, DISPATCH_SYNC } from "@open-pioneer/reactivity";

    function CustomForm() {
    const context = usePropertyFormContext();
    const name = useReactiveSnapshot(() => context.properties.get("name") ?? "", [context], DISPATCH_SYNC);

    useEffect(() => {
    context.isValid = name.length >= 1;
    }, [context, name]);

    return (
    <input
    value={name}
    onChange={(e) => context.properties.set("name", e.target.value)}
    />
    );
    }