Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@egjs/react-flicking] firstPanelSize prop also should be declared in DEFAULT_PROPS #882

Open
yongholeeme opened this issue Aug 20, 2024 · 1 comment
Assignees
Labels
🔖4.x v4.x~ related issue 🐛Bug Bugs

Comments

@yongholeeme
Copy link

Description

The firstPanelSize prop is being passed to a DOM element, which causes a warning message in React. To resolve this, the firstPanelSize prop should be declared in DEFAULT_PROPS to prevent it from being passed to the DOM element.

The following warning message appears:

Warning: React does not recognize the `firstPanelSize` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `firstpanelsize` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
    at div
    at Flicking (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/@[email protected]_patch_hash=udhpmtst4xgefa6rulabjuz4nu/node_modules/@egjs/react-flicking/dist/flicking.esm.js:492:24)

This warning occurs because the firstPanelSize prop is being passed to a DOM element, which React does not recognize. When an unknown prop is passed to a DOM element, React issues a warning.

To prevent the firstPanelSize prop from being passed to the DOM element, it should be declared in the component’s DEFAULT_PROPS. This will ensure that React does not forward the prop to the DOM element.

Relevant code:

  • for (const name in props) {
    if (!(name in DEFAULT_PROPS) && !(name in VanillaFlicking.prototype)) {
    attributes[name] = props[name];
    }
    }
  • export const DEFAULT_PROPS: FlickingProps = {
    viewportTag: "div",
    cameraTag: "div",
    cameraClass: "",
    renderOnSameKey: false,
    plugins: [],
    useFindDOMNode: false,
    hideBeforeInit: false,
    onReady: (e: ReadyEvent) => {},
    onBeforeResize: (e: BeforeResizeEvent) => {},
    onAfterResize: (e: AfterResizeEvent) => {},
    onHoldStart: (e: HoldStartEvent) => {},
    onHoldEnd: (e: HoldEndEvent) => {},
    onMoveStart: (e: MoveStartEvent) => {},
    onMove: (e: MoveEvent) => {},
    onMoveEnd: (e: MoveEndEvent) => {},
    onWillChange: (e: WillChangeEvent) => {},
    onChanged: (e: ChangedEvent) => {},
    onWillRestore: (e: WillRestoreEvent) => {},
    onRestored: (e: RestoredEvent) => {},
    onSelect: (e: SelectEvent) => {},
    onNeedPanel: (e: NeedPanelEvent) => {},
    onVisibleChange: (e: VisibleChangeEvent) => {},
    onReachEdge: (e: ReachEdgeEvent) => {},
    onPanelChange: (e: PanelChangeEvent) => {}
    };

Steps to check or reproduce

just pass firstPanelSize prop into <Flicking />

@malangfox malangfox self-assigned this Sep 2, 2024
@malangfox malangfox added 🐛Bug Bugs 🔖4.x v4.x~ related issue labels Sep 2, 2024
@malangfox
Copy link
Contributor

Hello @yongholeeme.

We fixed this issue in #886 and released @egjs/[email protected], which resolves this issue.

We'll leave additional comment when this PR is merged and we release the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔖4.x v4.x~ related issue 🐛Bug Bugs
Projects
None yet
Development

No branches or pull requests

2 participants