-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Move prepareContext
into store.getStoryContext()
#22135
Conversation
This way any consumer of the context will get the properly mapped args. Also store the unmapped args on the context
cc3dd8c
to
d45d3d3
Compare
@@ -103,48 +103,4 @@ describe('StoryRender', () => { | |||
await render.renderToElement({} as any); | |||
expect(story.playFunction).not.toHaveBeenCalled(); | |||
}); | |||
|
|||
it('passes the initialArgs to loaders and render function if forceInitialArgs is true', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality moved to the store so not really much point unit testing it here. We have a unit test in the story and an integration test in PreviewWeb.test.ts
code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🥳
…context Core: Move `prepareContext` into `store.getStoryContext()`
This way any consumer of the context will get the properly mapped args.
Closes #22099
What I did
The issue was that although the source decorator emitted the mapped/conditional args, references to
store.getStoryContext().args
would return the unmapped args.This is due to #20755 which moved the mapping to before the decorator chain.
This PR moves the mapping slightly earlier, so the
context.args
is mapped everywhere (not just inside decorators/render). That will make them inconsistent withcontext.initialArgs
, but I think that's probably OK? I'm not sure, this might be considered to risky a change.In which case we could consider just calling
prepareContext
in theSource
block.FTR, this inconsistency between
context.args
+context.initialArgs
is already the case inside the decorator stack/render function, so this would only affect outside callers ofstore.getStoryContext()
, which I'm not sure there are any.How to test
Checklist
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]