New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fake-react2

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fake-react2

Fake React

latest
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

Fake React

React 동작 방식을 이해하기 위해 만들어보는 가짜 리액트.

Goals.

  • JSX Rendering.
  • Detect Changes of State and Props.
  • React Component.
    • Claas Component
    • Function Component
  • Lifecycle.
    • DidMount()
    • DidUpdte()
  • Event delegation.

How to test

Installation

npm i fake-react2

Setup babel

{
  //
  // ... omitted
  //
  "plugins": [
    [
      "@babel/plugin-transform-react-jsx",
      {
        "runtime": "automatic",
        "importSource": "fake-react2"
      }
    ]
  ]
}

@babel/preset-react 를 사용해도 됩니다.

Usage

import { renderRoot, Component } from 'fake-react2';

class Counter extends Component {
  init() {
    this.state = {
      count: 0,
    };
  }

  increase = () => {
    this.setState({ count: this.state.count + 1 });
  };

  decrease = () => {
    this.setState({ count: Math.max(this.state.count - 1, 0) });
  };

  render() {
    return (
      <div>
        <span>{this.state.count}</span>
        <button onClick={() => this.increase()}>+</button>
        <button onClick={() => this.decrease()}>-</button>
      </div>
    );
  }
}

class App extends Component {
  render() {
    return <Counter />;
  }
}

const root = document.getElementById('root');
renderRoot(<App />, root);

Keywords

react

FAQs

Package last updated on 09 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts