2.2.3 • Published 9 years ago
react-komposer-plus v2.2.3
React Komposer Plus
This is fork of React Komposer
Let's compose React containers and feed data into components. Supports both React and React Native.
Installation
npm i --save react-komposer-plusBasic Usage
import ComponentA from 'path/to/ComponentA';
import { PropTypes } from 'react';
import {
withHandlers,
getContext,
withRedux,
withState,
withLifecycle,
composeAll,
} from 'react-komposer-plus';
import { useDeps } from 'mantra-plus';
const mapStateToProps = ({ layout }) => ({
windowWidth: layout.windowWidth,
windowHeight: layout.windowHeight,
windowScrollTop: layout.windowScrollTop,
});
export default composeAll(
withLifecycle({
componentWillMount() {
console.log('component will mount');
},
componentDidMount() {
console.log('component mounted');
},
}),
withHandler({
handleClickCounter: (props, event) => {
props.setState({
counter: props.state + 1,
});
},
}),
withRedux(mapStateToProps),
withState({
counter: 1,
}),
getContext({
parentCtx: PropTypes.object,
}),
useDeps()
)(ComponentA);In your functional stateless ComponentA, you can now use props to do your thing! Please take note that props flow from bottom to top of composeAll.
export default const ComponentA = ({
state,
setState,
windowWidth,
windowHeight,
windowScrollTop,
handleClickCounter,
}, context) => {
return (
<div>
<h1>current counter value: {state.counter}</h1>
<button onClick={handleClickCounter}>Increase counter value</button>
<h1>Window Information</h1>
<ul>
<li>Window Height: {windowHeight}</li>
<li>Window Width: {windowWidth}</li>
<li>Window ScrollTop: {windowScrollTop}</li>
</ul>
</div>
);
}Full APIs
See here
2.2.3
9 years ago
2.2.2
9 years ago
2.2.1
9 years ago
2.2.0
9 years ago
2.1.5
9 years ago
2.1.4
9 years ago
2.1.3
9 years ago
2.1.2
9 years ago
2.1.1
9 years ago
2.1.0
9 years ago
2.0.8
9 years ago
2.0.7
10 years ago
2.0.6
10 years ago
2.0.5
10 years ago
2.0.4
10 years ago
2.0.3
10 years ago
2.0.2
10 years ago
2.0.1
10 years ago
2.0.0
10 years ago