0.0.9 • Published 6 years ago

compx v0.0.9

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

CompX - Still in active development / Incomplete

Due to lack of interest and motivation, this library won't be developed any further

Very simple react state management library that uses react setState to populate a global state accessible to other components

Usage

Provider

import { Provider } from 'compx';
...
render() {
    return (
      <Provider>
        <ComponentA />
        <ComponentB />
      </Provider>
    );
}

Connect

  • ComponentA
import React, { Component } from 'react';
import {Connect} from 'compx';

class ComponentA extends Component {
    constructor(props) {
        super(props);
        this.state = {
            number: 0;
        }
    }
    render() {
        <button>Counter: {this.state.number}</button>
    }
}
export default Connect()(ComponentA);
  • ComponentB
import React, { Component } from 'react';
import {Connect} from 'compx';

class ComponentB extends Component {
    render() {
        <p>ComponentA counter is {this.props.CompX.ComponentA} </p>
    }
}
export default Connect({subscribeTo: ['ComponentA']})(ComponentB);
0.0.9

6 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago