@business-nxt/app-messaging-react
v3.0.2
Published
React hooks on top of [`@business-nxt/app-messaging`](../app-messaging/README.md) for building Business NXT partner apps.
Readme
@business-nxt/app-messaging-react
React hooks on top of @business-nxt/app-messaging for building Business NXT partner apps.
Re-exports everything from @business-nxt/app-messaging (so you can import SendMessage, ExecuteGraphQL, the message types, etc. from this package) plus the hooks below.
Hooks
useSelection(options?)- subscribes toselection-statemessages and returns the latestSelectionStateMessage | undefined. Options:filter(predicate),defaultValue,toParent(ask for the parent table's selection on the initial fetch).useEditStatus(defaultValue?, options?)- subscribes toedit-sessionmessages and returns the latestEditSessionMessage | undefined. Options:filter.
import { useSelection } from "@business-nxt/app-messaging-react";
function App() {
const selection = useSelection({ filter: (s) => !s.fromParent });
return <pre>{JSON.stringify(selection, null, 2)}</pre>;
}Compatibility
Supports React 18 and 19 (peer dependency ^18 || ^19), verified against both. The hooks use only stable APIs (useState, useEffect, useRef) and the package's public types expose no React-specific types, so it is version-agnostic across those majors.
