Skip to content

[core] early return required #111

@einar-hjortdal

Description

@einar-hjortdal

Note: maybe I am forgetting something.

I have noticed that, in this component, I am required to use an early return null:

If I instead did the following (only returning when requiresShipping is true):

const Properties = component(({ inventoryItemData, onInput }) => {
  const { requiresShipping, material, weight, length, height, width } = inventoryItemData
  const { t } = useTranslation('inventoryItems.shipping.properties')
  if (requiresShipping) {
  return (
    <>
    ...

What happens is that, whenever requiresShipping switches from true to false, the Properties component is still being rendered. Then when requiresShipping switches from false to true, a new Properties component is rendered below the old one.

Why does this happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions