Repository navigation
docs: fix runnable recipes and tutorial examples - #266
dajiaohuang wants to merge 3 commits into
Conversation
dai-shi
left a comment
There was a problem hiding this comment.
Nice catch. Thanks for the suggestions.
| const App = () => ( | ||
| <Provider> | ||
| ... | ||
| </Provider> | ||
| ); | ||
| const App = () => <Provider>...</Provider>; |
There was a problem hiding this comment.
Can we keep the multiline style?
There was a problem hiding this comment.
Restored the original multiline style in both affected Provider examples in a6f388f, keeping the syntax and import fixes unchanged. This follow-up only changes documentation formatting; checked the exact diff and whitespace, without rerunning the earlier React/site tests.
There was a problem hiding this comment.
can you check CI error? it's probably complaining because the syntax is correct now. ... might need to be {/* ... */} or something.
There was a problem hiding this comment.
Checked the failing job (run 38861492502, job 117242550207). The failure is not a JSX syntax error: pnpm test runs test:format, test:lint, test:types and test:spec together, and it stopped at test:format, which reported a Prettier code-style issue on website/docs/recipes.md and exited 1. The spec suite never started, so the ... lines were not the reported error, and no library code is involved.
The format step fails because Prettier reflows the two multiline Provider/App examples back onto a single line, i.e. it would undo the layout you asked to keep in #266 (comment). The minimal fix is to keep the multiline layout and mark those two declarations, so the pushed commit 2b9f2db only adds // prettier-ignore above each const App = ... in that file — two added comment lines, no other change.
Verified locally against this PR head: using the repo's own pinned Prettier 3.4.2 from pnpm-lock.yaml with the package.json prettier config, prettier --check website/docs/recipes.md fails on the previous head (a6f388f) and passes on 2b9f2db. I did not re-run the rest of the suite or trigger a new workflow run, so the other steps are still unverified by me.
Mark the two Provider/App examples restored for review so prettier leaves their multiline layout intact, fixing the test:format failure.
|
|
||
| } = createContainer(({ initialState }) => useState(initialState)); | ||
|
|
||
| // prettier-ignore |
There was a problem hiding this comment.
How about this?
const App = ({ initialState }) => (
<Provider initialState={initialState}>
{/* ... */}
{/* ... */}
{/* ... */}
</Provider>
);
Summary
Fix copy/paste failures in the existing examples and documentation without changing the library API:
01_counterand02_person, which exist in the current examples directory.createContainercalls in the twouseStaterecipes.useDispatch, which its store does not export, and match its flasher ref to the rendereddiv.produceexport in the recipe and Immer tutorial, compatible with the Immer 10 dependency used by this repository.Reproduction and validation
Local fixtures were extracted from the documented snippets (not added to the repository):
TypeError: ...default is not a function, leaving the displayed todo unchanged.git diff --checkpasses.The browser/Puppeteer example suite was not run. These are isolated DOM checks, not browser visual or all-version compatibility certification.