docs: use prop atoms directly in counter and tabs examples#11
Merged
Conversation
size-limit report 📦
|
ctx.props.$active is already a WritableAtom; drop the redundant local copy and the unused atom import.
Rename the seed prop to "value" and drive it via ctx.props.$value (already a WritableAtom); drop the unused atom import.
5c924ee to
8f45443
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Simplifies the Counter and Tabs documentation examples to use their prop atoms directly instead of copying them into redundant local atoms. Addresses issue #10.
Problem Statement
Both examples created a new Nano Stores atom seeded from a prop (
atom(ctx.props.$x.get())), even thoughctx.props.$xis already aWritableAtom. As reported in #10, this made the examples harder to follow: it added an extra concept, an extrananostoresimport, and suggested the copy was necessary when it wasn't. In Tabs the local$activewas a one-to-one mirror of theactiveprop, and in Counter the seeded$countcould be expressed directly through the prop.Solution Approach
ctx.props.$activedirectly in the focus handler, click handler, effect, and context provider; removed the redundant$activecopy.initialprop tovalueand read/writectx.props.$valuedirectly for increment, decrement, and display.atomimport and the orphanednanostoresimportmap entry from both examples, keeping them self-contained and consistent with the other examples.Breaking Changes
None. Documentation examples only.