cvazac/eslint-plugin-react-perf

Support for non-JSX render functions

Opened this issue · 5 comments

Hi!

I just wondered if you had thought of also supporting non-JSX usages of React, where object/function identity is still a performance concern?

Thanks,
Oliver

We could also consider extending scope from objects/functions inside JSX to the whole render function, so this would error:

const MyComponent = () => {
  const toObject = { pathname: '/foo' };

  return <Link to={toObject}>foo</Link>;
};

Yes! That was always part of the plan. Let me know if you are interested in contributing.

@cvazac Is that yes to both ideas?

  1. Support non-JSX usages, e.g. React.createElement(MyComponent, { objectProp: {} })
  2. Support usages outside of virtual DOM but inside render functions

I think both are important, but I'd prioritize 2 over 1. I had always planned to (attempt to) read more of the scope.

We report on:

  render() {
    return <Tag obj={{}} />
  }

But it's easily defeated with:

  render() {
    var o = {}
    return <Tag obj={o} />
  }

@cvazac If it's OK with you, I'll open another issue to track 2, as I originally created this issue to track 1.