Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

react-subcomponent

A stateless react component

Usage

Parent that holds state:

importReactfrom'react';importChildfrom'./child.js';classParentextendsReact.Component{constructor(props){super();this.state={// some state}}render(){return(<Childparent={this}/>);}}

Child that has no state but can access and set its parents state:

importReactfrom'react';importSubComponentfrom'react-subcomponent';classChildextendsSubComponent{handleClick(){this.setState({})// sets parents state}render(){return(<divonClick={this.handleClick.bind(this)}>{this.state} // gets parents state
</div>);}}

About

A stateless react component

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages