Redux fancy
Manage your ui state with redux.
Installation
npm install --save redux-fancy
Get started
MyCustomUiComponent.js
const MyCustomComponent = ({setState, isLoading}) =>
<div onClick = {() => setState({isLoading: false})}>
{ isLoading && "I'm loading!" }
{ !isLoading && "I've stopped loading... :(" }
</div>
export default MyCustomComponent;
Each component gets through props setState
function that behaves similar to react setState, and
all the props that were passed through initial state.
MyCustomComponent.js
import fancy from 'redux-fancy';
import MyCustomComponent from './MyCustomUiComponent';
const Component = fancy({
name: 'FancyComponent',
initialState: {
isLoading: true
}
})(MyCustomComponent);
export default Component;
In your app render component.
<Provider>
<Component />
</Provider>