Socket
Socket
Sign inDemoInstall

redux-fractal

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-fractal - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

3

dist/local.js

@@ -106,5 +106,6 @@ 'use strict';

value: function componentWillUnmount() {
var persist = typeof Config.persist === 'function' ? Config.persist(this.props) : Config.persist;
this.context.store.dispatch({
type: UIActions.UNMOUNT_COMPONENT,
payload: { persist: Config.persist },
payload: { persist: persist },
meta: { triggerComponentKey: this.key }

@@ -111,0 +112,0 @@ });

{
"name": "redux-fractal",
"version": "1.1.0",
"version": "1.2.0",
"description": "A local component state management library using Redux",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -331,2 +331,31 @@ # redux-fractal

```
If there are multiple instance of MyComponent, using `persist` as shown above will persist the state of ALL instances.
You can have fine grained control over which component instances get persisted and which do not
by defining `persist` as a function receiving the component props.
```js
const HOC = local({
key: (props) => props.itemId,
createStore: (props, existingState) => {
return createStore(
rootReducer,
existingState || { filter: true }
);
},
// Any logic depending on props here to decide if the component state should be persisted
persist: (props) => props.keepState
});
const ConnectedItem = HOC(Item);
const App = (props) => {
return (
<div>
<ConnectedItem itemId={'a'} keepState={true} />
<ConnectedItem itemId={'b'} keepState={false} />
</div>
);
}
```
In the above example only the state of component with itemId 'a' will be kept in the global
state after the component unmounts.
### I need to read a component's state somewhere else: eg in thunk action creators, sagas, in `mapStateToProps`

@@ -333,0 +362,0 @@ All the local components state is available at `state.local[key]` where `key` is the key for the component

@@ -59,5 +59,7 @@ import React from 'react';

componentWillUnmount() {
const persist = typeof Config.persist === 'function' ?
Config.persist(this.props) : Config.persist;
this.context.store.dispatch({
type: UIActions.UNMOUNT_COMPONENT,
payload: { persist: Config.persist },
payload: { persist: persist },
meta: { triggerComponentKey: this.key }

@@ -64,0 +66,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc