Bug: ops.ctx is undefined inside action execution despite __ctx__ definition
Description
According to the FractoState documentation, actions exposed through __ctx__ should be accessible via ops.ctx.
However, when an action attempts to access a method exposed by __ctx__, ops.ctx is undefined, causing a runtime crash.
Error
Uncaught TypeError: Cannot read properties of undefined (reading 'getTitle')
at store/meta.ts:42:24
return ops.ctx.getTitle(docsConfig, pathname);
Reproduction
export const MetaFlow = defineFlow(
"meta",
initialState,
{
actions: {
__ctx__(c) {
return {
getTitle: (docsConfig: any[], pathname: string) => {
const actions = c.actions;
const title = actions.findTitleInConfig(
docsConfig,
pathname
);
return title;
},
};
},
getDTitle: () => (ops) => {
const pathname =
typeof window !== "undefined"
? window.location.pathname
: "";
return ops.ctx.getTitle(
docsConfig,
pathname
);
},
findTitleInConfig: (items: any[], path: string) => (ops) => {
// implementation omitted
},
},
}
);
Expected behavior
ops.ctx should contain the object returned by __ctx__.
Example:
should execute successfully.
Actual behavior
ops.ctx is undefined:
TypeError:
Cannot read properties of undefined (reading 'getTitle')
Environment
- FractoState version: latest
- React
- Next.js
- Client Component (
"use client")
Additional notes
The documentation appears to indicate that __ctx__ values are exposed through ops.ctx, so either:
__ctx__ is not being initialized correctly for action execution.
ops.ctx is unavailable in certain execution contexts.
- The documentation is outdated and another API should be used.
Could you clarify the intended usage of __ctx__ and whether ops.ctx should be available inside actions and effects?
Bug:
ops.ctxis undefined inside action execution despite__ctx__definitionDescription
According to the FractoState documentation, actions exposed through
__ctx__should be accessible viaops.ctx.However, when an action attempts to access a method exposed by
__ctx__,ops.ctxisundefined, causing a runtime crash.Error
Reproduction
Expected behavior
ops.ctxshould contain the object returned by__ctx__.Example:
should execute successfully.
Actual behavior
ops.ctxis undefined:Environment
"use client")Additional notes
The documentation appears to indicate that
__ctx__values are exposed throughops.ctx, so either:__ctx__is not being initialized correctly for action execution.ops.ctxis unavailable in certain execution contexts.Could you clarify the intended usage of
__ctx__and whetherops.ctxshould be available inside actions and effects?