Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 1.07 KB

README.md

File metadata and controls

84 lines (60 loc) · 1.07 KB

react-ioc

how about react in Ioc? :)

# from github
git clone https://github.com/Saber2pr/react-ioc.git

Feature

@Injectable()
class CountService {
  @InjectProp() private System: System

  private count = 1

  getCount() {
    return this.count
  }

  add() {
    this.count++
    this.System.update()
  }
}

@Injectable()
export class Count implements Component {
  @InjectProp() private CountService: CountService

  render() {
    return (
      <button onClick={() => this.CountService.add()}>
        {this.CountService.getCount()}
      </button>
    )
  }
}

@Application
export class App implements Component {
  @InjectProp() private Count: Count

  render() {
    return (
      <div>
        <h1>hello</h1>
        {this.Count.render()}
      </div>
    )
  }
}

maybe we don't need the React.Component, we need jsx only!


start

npm install
npm start

npm run dev

Author: saber2pr


develope and test

you should write ts in /src

you should make test in /src/test

export your core in /src/index.ts!