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

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

Open
yarastqt opened this issue Dec 9, 2020 · 1 comment
Open

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

yarastqt opened this issue Dec 9, 2020 · 1 comment

Comments

@yarastqt
Copy link
Member

yarastqt commented Dec 9, 2020

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.

@yarastqt
Copy link
Member Author

yarastqt commented Dec 9, 2020

I think we should try pass "internal key" for nextProps and say for react not update this component from initial.

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

No branches or pull requests

1 participant