Skip to content

Chore/cleanup and comment rationale#35

Merged
u8array merged 4 commits into
mainfrom
chore/cleanup-and-comment-rationale
May 9, 2026
Merged

Chore/cleanup and comment rationale#35
u8array merged 4 commits into
mainfrom
chore/cleanup-and-comment-rationale

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 9, 2026

No description provided.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the ImageObject component to handle image cache resets during the render phase rather than within an effect, which aligns with React best practices for prop-driven state updates. Additionally, it removes redundant TypeScript type assertions, adds explanatory comments for complex casts in BarcodeObject, and deletes a significant amount of unused CSS. I have no feedback to provide as there were no review comments to evaluate.

u8array added 4 commits May 9, 2026 10:10
Leftover from the Vite template — defines .counter, .hero, #docs etc.
which the app never references. Tailwind is loaded via index.css and
the @tailwindcss/vite plugin.
After narrowing obj.type to 'text' or 'serial', TypeScript already
narrows obj.props to TextProps | SerialProps via the LabelObject
discriminated union. Both members declare fontHeight: number and
rotation: 'N'|'R'|'I'|'B', so the inline cast was just widening
rotation to string for no reason.
ImageObject reset its htmlImg state from inside useEffect with an
eslint-disable for react-hooks/set-state-in-effect. Switch to the
official React 'adjusting state on prop change during render' pattern:
a useRef tracks the previous cached.dataUrl, and a render-time
comparison resets htmlImg before paint. Same observable behaviour,
no lint exception, and the next render naturally observes the
updated ref so there's no loop.
The cast bridges our Record<string, unknown> options builder (which
varies per barcode type) and bwip-js' strict literal-string union
signature. Document the trade-off so future readers don't try to
'fix' the cast by re-typing buildBwipOptions per type — that would
duplicate the per-type switch already inside buildBwipOptions.
@u8array u8array force-pushed the chore/cleanup-and-comment-rationale branch from 3da4bf7 to 4c18afc Compare May 9, 2026 08:12
@u8array u8array merged commit 36abfac into main May 9, 2026
2 checks passed
@u8array u8array deleted the chore/cleanup-and-comment-rationale branch May 9, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant