fix: correct ComponentPropsProvider usage in 8 background demos#955
Open
KhaledSaeed18 wants to merge 1 commit intoDavidHDev:mainfrom
Open
fix: correct ComponentPropsProvider usage in 8 background demos#955KhaledSaeed18 wants to merge 1 commit intoDavidHDev:mainfrom
KhaledSaeed18 wants to merge 1 commit intoDavidHDev:mainfrom
Conversation
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.
fix: correct ComponentPropsProvider usage in 8 background demos
Problem
Several background demo components had incorrect or incomplete
ComponentPropsProviderusage, causing two distinct bugs:Bug 1: Reset button visible but non-functional
ComponentPropsProvideraccepts aresetPropsprop that wires the reset button inTabsLayout. Some demos either passed it under the wrong name (reset=instead ofresetProps=) or used a completely wrong interface (value={{ ... }}), causing the context to fall back to its default no-opresetProps: () => {}. The reset button would appear (becausehasChangeswas passed correctly) but clicking it did nothing and URL state was never cleared.Bug 2: "Copy Prompt" ignores user customizations
ComponentPropsProvideralso acceptspropsanddefaultPropswhich are consumed byTabsLayout's "Copy Prompt" feature to inject the user's current customized values into the usage code snippet. Without these, the copied AI prompt always contained the static default usage example, silently ignoring any prop changes the user had made.Bug 3: Dead code (
useForceRerenderunused)Three demos declared
useForceRerenderand passedforceRerendereither to the provider (which doesn't accept it) or nowhere at all. Thekey={key}was applied to the component but sinceforceRerenderwas never called, the key never changed, making both the hook and the key entirely dead code.How to Reproduce
Example 1: Reset button appears but does nothing
URL: https://www.reactbits.dev/backgrounds/silk
Root cause:
ComponentPropsProviderwas receivingreset={resetProps}(wrong prop name) instead ofresetProps={resetProps}, so the context fell back to its default no-op function.Example 2: Reset button not shown at all
URL: https://www.reactbits.dev/backgrounds/ripple-grid
Root cause:
ComponentPropsProviderwas receiving avalue={{ ... }}object (wrong interface entirely), sohasChangesandresetPropswere bothundefinedin the context, the button never rendered and had no handler.Changes
SilkDemo.jsxreset={resetProps}→resetProps={handleReset}(wrong prop name)props={props}anddefaultProps={DEFAULT_PROPS}handleResetcombiningresetProps()+forceRerender()so the component remounts on reset (required because Silk useskey={key}to remount its WebGL context on every prop change)useCallbackimportRippleGridDemo.jsxvalue={{ props, updateProp, resetProps, hasChanges, forceRerender, DEFAULT_PROPS }}interface — replaced with correct individual propsuseForceRerenderimport, hook call, andkey={key}on the component (none of theonChangehandlers calledforceRerender, so key never changed)GridScanDemo.jsxprops={props}anddefaultProps={DEFAULT_PROPS}forceRerender={forceRerender}from provider (unrecognized prop, silently ignored)useForceRerenderimport, hook call, andkey={key}on the componentPlasmaDemo.jsxprops={props}anddefaultProps={DEFAULT_PROPS}forceRerender={forceRerender}from provider (unrecognized prop, silently ignored)useForceRerenderimport, hook call, andkey={key}on the componentGradientBlindsDemo.jsxprops={props}anddefaultProps={DEFAULT_PROPS}LetterGlitchDemo.jsxprops={props}anddefaultProps={DEFAULT_PROPS}LiquidChromeDemo.jsxprops={props}anddefaultProps={DEFAULT_PROPS}GridDistortionDemo.jsxprops={props}anddefaultProps={DEFAULT_PROPS}Root Cause
All affected demos were missing one or more required props on
ComponentPropsProvider. The correct interface is:SilkDemoadditionally neededresetPropsto callforceRerender()because the Silk component relies onkeyremounting to apply changes to its WebGL context, matching the pattern already used inSplashCursorDemo.Checklist
ComponentPropsProvider