open-index/open-npm huggingface dataset:
npm package: @ishawnwang/config-ts
Description: Read `.ts` config file with ease :D
Author: iShawnWang
Latest version: 1.0.1

# Config-TS

Read `.ts` config file with ease :D

# Getting Started

Many node cli or bundler use `.json .js` as their config file, but it woule be better with `.ts`

This lib is `Designed` as a util to simplify this process.
It's simplely rely on `typescript compiler API`, just compile the `.ts` config file to the tmpDir then `require` it.

```
import getConf from 'config-ts'

const config = getConf(<your config file full path>) // return a js object
```
npm package: @ishawnwang/withunmounted
Description: HOC for set a flag when componentWillUnmount, bypass `Can't perform a React state update on an unmounted component` warning
Author: iShawnWang
Latest version: 1.0.1

# withUnmounted

![](https://img.shields.io/npm/v/@ishawnwang/withunmounted.svg) ![](https://img.shields.io/david/iShawnWang/withUnmounted.svg) ![](https://img.shields.io/bundlephobia/minzip/@ishawnwang/withunmounted.svg) ![](https://img.shields.io/npm/l/@ishawnwang/withunmounted.svg)

HOC for set a `hasUnmounted` flag when `componentWillUnmount`, bypass `Can't perform a React state update on an unmounted component` warning

# Install

`npm install --save @iShawnWang/withUnmounted`

# Usage

`import withUnmounted from '@ishawnwang/withunmounted'`

```javascript
class YourCompoment extends Component {
  hasUnmounted = false;

  componentDidMount() {
    fetch(url).then(resp => {
      if (this.hasUnmounted) {
        // check hasUnmounted flag
        return;
      }
      this.setState({ resp });
    });
  }
}

export default withUnmounted(YourCompoment);
```

# Detail

`Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.`

According to official document, it's fine to call `setState` in `componentWillUnmount`, it won't produce any unpredicable effect, just a warning should be ignore.

![](https://ws1.sinaimg.cn/large/006tNc79gy1g01bg2otrij31f60nigv4.jpg)

# Additional Infos

> https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html