Skip to content

@bem-react/core: Recreated component after modifier changed #589

Description

@yarastqt

Info

If we have complex modifier, and we enabled this dynamically then component will be created again, and focus will be removed from component.

Example

modifier:

export const withClear = withBemMod('Component', { clearable: true }, (Component) => {
  return function WithClear() {
    return <Component icon={<div>X</div>} />
  }
})

usage:

function App() {
  const [clearable, setClearable] = React.useState(false)
 
  React.useEffect(() => {
    setTimeout(() => setClearable(true), 1000)
  }, [])
 
  return (
    <Component  clearable={clearable} />
  )
}

Expected behavior

Component should update without focus side-effects.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions