react-hook-component

0.1.0 • Public • Published

react-hook-component

With the React hooks the React.Component will be deprecated soon ⚰️. Not only this new hook all-functional API is disgusting 🤢, it also forces us to rewrite our apps, which takes greater than zero hours 💰. This project allows you to write your react components in the old-fasioned way, as you love ❤️ and are used to do. No need to learn new react, which will be deprecated in a year anyway.

Example

import React from "react";
import createComponent from "react-hook-component";
 
// Our component definition looks like in the good old days 🤩
const Counter = createComponent({
  getInitialState() {
    return {
      count: 0
    };
  },
 
  handleIncrement() {
    this.setState({
      count: this.state.count + 1
    });
  },
 
  handleDecrement() {
    this.setState({
      count: this.state.count - 1
    });
  },
 
  render() {
    const { count } = this.state;
 
    return (
      <div>
        <span>{count}</span>
        <button onClick={this.handleIncrement}>+</button>
        <button onClick={this.handleDecrement}>-</button>
      </div>
    );
  }
});

Tests

See test.js

TODO

  • [] - implement getDefaultProps
  • [] - implement forceUpdate
  • [] - tests for state, props
  • [] - test shouldComponentUpdate when enzyme ready

Feel free to open PR if you want to help!

Readme

Keywords

none

Package Sidebar

Install

npm i react-hook-component

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

193 kB

Total Files

7

Last publish

Collaborators

  • miroslavpetrik