jasonmorita / react-redux-ui-state Goto Github PK
View Code? Open in Web Editor NEWReact higher order component to provide UI state for components.
Home Page: https://www.npmjs.com/package/react-redux-ui-state
License: MIT License
React higher order component to provide UI state for components.
Home Page: https://www.npmjs.com/package/react-redux-ui-state
License: MIT License
Need to upgrade and test.
Could this be a consideration? Either by default or as an option?
It would mean not resetting the state when a component is unmounted?
I noticed that using immutablity-helper was slower than Immutable.
Good day!
I'm facing an issue where different uiState-wrapped components trigger a re-render whenever the uiState state object is updated. This makes sense, since we're using immutablity-helper
to return a new copy of the uiState object with the updated sub-states, but the trouble is that I end up with the re-rendering of completely separate components that happen to share in uiState, affecting the performance of my application.
For example, if we have two separate Component1
and Component2
:
class Component1 extends React.Component {
constructor(props) {
super(props);
}
onDivClick = () => {
this.props.setUiState({ uiC1Active: !this.props.uiC1Active })
}
render() {
return (
<div onClick={this.onDivClick}>
<h1> Component 1</h1>
</div>
);
}
}
const uiStateConfig = {
name: () => `Component1`,
state: (props) => ({
uiC1Prop: 'uiProp',
}),
};
export default connectedComponent1 = compose(
uiState(uiStateConfig),
)(Component1);
And Component2:
class Component2 extends React.Component {
constructor(props) {
super(props);
}
onDivClick = () => {
this.props.setUiState({ uiC2Active: !this.props.uiC2Active })
}
render() {
return (
<div onClick={this.onDivClick}>
<h1> Component 2 </h1>
</div>
);
}
}
const uiStateConfig = {
name: () => `Component2`,
state: (props) => ({
uiC2Prop: 'uiProp',
}),
};
export default connectedComponent2 = compose(
uiState(uiStateConfig),
)(Component2);
Clicking on Component1
's div will trigger a re-render for Component1
as well as Component2
, and in fact any other components that happen to have their own uiState slice.
Is this by design, and is there a way get around this?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.