Setting the file. One moment.
Subchapter 2.9
references/auto-patterns-dashboard/app-context.mdMarkdown955 BView on GitHub
interface AppContext {
items: any[];
refreshCollection: () => void;
}useAppContext THEN component MUST be inside AutoPatternsApp (as children).<AutoPatternsApp>.useAppContext to access shared collection data/refresh.refreshCollection after data mutations in external components.useAppContext outside of the AutoPatternsApp tree.// 1. Child Component
const MyModal = () => {
const { items, refreshCollection } = useAppContext();
return (
<Modal>
<Text>Count: {items.length}</Text>
<Button onClick={refreshCollection}>Refresh</Button>
</Modal>
);
};
// 2. Integration
<AutoPatternsApp configuration={config}>
<MyModal />
</AutoPatternsApp>