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

Rule: no-direct-event-calls-in-components #111

Open
sergeysova opened this issue Aug 2, 2022 · 0 comments
Open

Rule: no-direct-event-calls-in-components #111

sergeysova opened this issue Aug 2, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@sergeysova
Copy link
Member

sergeysova commented Aug 2, 2022

It can be useful for SSR or SPA with testing approaches.

Should ban direct calls of effector events inside React/Solid components.

Fail:

// no-direct-event-calls-in-components: 'error'
import { somethingHappened } from './model'; // Event

function Example() {
  // Should suggest to wrap it with `useEvent` from "effector-react/scope"
  return <div onClick={() => somethingHappened()} />
}

Okay:

// no-direct-event-calls-in-components: 'error'
import { useEvent } from 'effector-react/scope';
import { somethingHappened } from './model'; // Event

function Example() {
  const handleClick = useUnit(somethingHappened);
  return <div onClick={() => handleClick()} />
}
@sergeysova sergeysova added the enhancement New feature or request label Aug 2, 2022
@sergeysova sergeysova changed the title Rule no-direct-event-calls-in-components Rule: no-direct-event-calls-in-components Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant