Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

kristinn93/CompX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published