Skip to content

Commit bb05088

Browse files
committed
refactor: centralize storybook queries key
1 parent 0cdcf89 commit bb05088

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

site/.storybook/preview.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ function withHelmet(Story) {
101101
);
102102
}
103103

104+
/**
105+
* This JSX file isn't part of the main project, so it doesn't get to use the
106+
* ambient types defined in `storybook.d.ts` to provide extra type-safety.
107+
* Extracting main key to avoid typos.
108+
*/
109+
const queryParametersKey = "queries";
110+
104111
/** @type {Decorator} */
105112
function withQuery(Story, { parameters }) {
106113
const queryClient = new QueryClient({
@@ -112,8 +119,8 @@ function withQuery(Story, { parameters }) {
112119
},
113120
});
114121

115-
if (parameters.queries) {
116-
for (const query of parameters.queries) {
122+
if (parameters[queryParametersKey]) {
123+
for (const query of parameters[queryParametersKey]) {
117124
queryClient.setQueryData(query.key, query.data);
118125
}
119126
}

0 commit comments

Comments
 (0)