npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

babel-plugin-hoist-facc

v0.2.3

Published

Babel plugin to hoist a FACC

Downloads

115

Readme

babel-plugin-hoist-facc

Note: This plugin was not intensively tested and was not actively used in production. Use it at one's own risk.

Treat FACC as value types and hoist them to the highest scope

Install

Using npm:

npm install --save-dev @babel/core babel-plugin-hoist-facc

or using yarn:

yarn add @babel/core babel-plugin-hoist-facc --dev

What problem it solves?

It solves the problem of rendering optimization, which comes with FaCC pattern. In a few words: Function as Child Component can't be optimized by shouldComponentUpdate because the child function is always changes on render.

This plugin hoist the child function to highest possible scope to prevent its changes.

Example

class extends React.Component {
  render() {
    return <FaCC>{() => <div />}</FaCC>; // arrow function changes on each render
  }
}

⇩⇩⇩

var _ref = () => <div />;

class extends React.Component {
  render() {
    return <FaCC>{_ref}</FaCC>; // now it's constant
  }
}

Options

| Option | Defaults | Description | | ------------------ | :------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | unsafeHoistInClass | false | When true, enables the hoisting of FaCC children function, which refers to this, to the class constructor. Potentially it is unsafe due to context losing issue, but in regular React life this shouldt happens. See example below. | | warnIfCantHoist | false | When true, display a warnings about child functions that couldn't be hoisted. | | loose | false | When true`, class properties are compiled to use an assignment expression instead of Object.defineProperty. |

More examples

["hoist-facc", { unsafeHoistInClass: true, loose: true }]

class extends React.Component {
  handleClick = () => {};

  render() {
    return <FaCC>{() => <button onClick={this.handleClick} />}</FaCC>;
  }
}

⇩⇩⇩

class extends React.Component {
  constructor(...args) {
    super(...args);

    this.handleClick = () => {};
    this._ref = () => <button onClick={this.handleClick} />;
  }

  render() {
    return <FaCC>{this._ref}</FaCC>;
  }
}

Pitfalls

There some cases it can't be hoisted automagically.

class extends React.Component {
  render() {
    const { id, label } = this.props;

    return <FaCC>{() => <div id={id}>{label}</div>}</FaCC>;
  }
}

The above code will not be transformed, because the id and label from the higher scope is used inside FaCC. You should proxy the props to the child function or access props directly trought this keyword to avoid this.

class extends React.Component {
  render() {
    return (
      <FaCC {...this.props}>
        {({ id }) => (
          <div id={id}>{this.props.label}</div>
        )}
      </FaCC>
    );
  }
}