next-persist
Advanced tools
Comparing version 1.1.2 to 1.1.3-alpha.0
{ | ||
"name": "next-persist", | ||
"version": "1.1.2", | ||
"version": "1.1.3-alpha.0", | ||
"description": "Bridging the gap between client-side persistence and server-side rendering", | ||
@@ -27,8 +27,13 @@ "main": "src/next-persist.js", | ||
"homepage": "https://github.com/oslabs-beta/next-persist#readme", | ||
"dependencies": { | ||
"devDependencies": { | ||
"cookie": "^0.4.1", | ||
"jest": "^26.6.3", | ||
"js-cookie": "^2.2.1", | ||
"react": "^17.0.2", | ||
"react-redux": "^7.2.3" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=16.8.3", | ||
"react-redux": ">=7.1.0" | ||
} | ||
} |
@@ -29,6 +29,6 @@ <p align="center"> | ||
<td width="60%"> | ||
<p>What is next-persist? next-persist is a lightweight NPM package developed to simplify the process of storing and reconciling non-critical persistent client data while retaining the benefits of server side rendering and static site generation through Next.js.</p> | ||
<p>Wouldn't it be nice to gain the benefits of Next.js while still providing the users with some sort of persistent dynamics? All without worrying about the architecture and costs of additional database management systems? | ||
<br> | ||
<p>'What is next-persist?' Well, next-persist is a lightweight NPM package developed to simplify the process of storing and reconciling non-critical persistent client state while retaining the benefits of server side rendering and static site generation provided by Next.js.</p> | ||
<p>Wouldn't it be nice to gain the benefits of Next.js while still providing the users with some sort of dynamic state persistence? How about without worrying about the design and added costs of additional database management systems? | ||
</p> | ||
<p> | ||
Well now you can! next-persist provides a simple solution for your dynamic, isomorphic web applications. Just import next-persist, set up a quick config and incorporate our functions. We do the rest, delivering you the benefits of server side rendering and persistent client data. | ||
@@ -245,3 +245,3 @@ </p> | ||
## **WARNING** - NEVER STORE UNENCRYPTED PERSONAL DATA TO CLIENT STORAGE | ||
### **WARNING** - NEVER STORE UNENCRYPTED PERSONAL DATA TO CLIENT STORAGE | ||
@@ -248,0 +248,0 @@ --- |
@@ -13,31 +13,30 @@ /** | ||
import { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { setCookie } from './next-persist-cookies'; | ||
import { setStorage } from './next-persist'; | ||
import { useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { setCookieStore } from './next-persist-cookieStore'; | ||
import { setLocalStore } from './next-persist-localStore'; | ||
const mapStateToProps = (state) => ({ | ||
state, | ||
}); | ||
const NextPersistWrapper = (props) => { | ||
const state = useSelector((state) => state); | ||
class NextPersistWrapper extends Component { | ||
render() { | ||
useEffect(() => { | ||
// determines method to persist state | ||
let method; | ||
if (this.props.wrapperConfig.method === 'localStorage') { | ||
method = setStorage; | ||
} else if (this.props.wrapperConfig.method === 'cookies') { | ||
method = setCookie; | ||
if (props.wrapperConfig.method === 'localStorage') { | ||
return setLocalStore; | ||
} else if (props.wrapperConfig.method === 'cookies') { | ||
return setCookieStore; | ||
} | ||
const { allowList } = this.props.wrapperConfig; | ||
const { allowList } = props.wrapperConfig; | ||
const nextPersistConfig = {}; | ||
// if no allowlist provided save all state to their corresponding keys | ||
// if no allowList - save all state to their corresponding keys | ||
if (!allowList) { | ||
const key = Object.keys(this.props.state)[0]; | ||
const key = Object.keys(state)[0]; | ||
nextPersistConfig[key] = []; | ||
method(nextPersistConfig, this.props.state[key]); | ||
method(nextPersistConfig, state[key]); | ||
} | ||
// if allowlist exists pass subconfigs of allowed reducers into storage method | ||
// if allowList - pass subconfigs of allowed reducers into storage method | ||
else { | ||
@@ -47,12 +46,10 @@ const allowedReducers = Object.keys(allowList); | ||
nextPersistConfig[allowedReducer] = allowList[allowedReducer]; | ||
method(nextPersistConfig, this.props.state[allowedReducer]); | ||
method(nextPersistConfig, state[allowedReducer]); | ||
}); | ||
} | ||
return this.props.children; | ||
} | ||
} | ||
}, [state]); | ||
// connects wrapper to redux store | ||
const PersistWrapper = connect(mapStateToProps)(NextPersistWrapper); | ||
return props.children; | ||
}; | ||
export default PersistWrapper; | ||
export default NextPersistWrapper; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20071
2
11
247
5
1
+ Added@types/use-sync-external-store@0.0.3(transitive)
+ Addedreact@18.3.1(transitive)
+ Addedreact-redux@9.1.2(transitive)
+ Addeduse-sync-external-store@1.2.2(transitive)
- Removedcookie@^0.4.1
- Removedjs-cookie@^2.2.1
- Removedreact@^17.0.2
- Removedreact-redux@^7.2.3
- Removed@babel/runtime@7.26.0(transitive)
- Removed@types/hoist-non-react-statics@3.3.5(transitive)
- Removed@types/prop-types@15.7.13(transitive)
- Removed@types/react@18.3.12(transitive)
- Removed@types/react-redux@7.1.34(transitive)
- Removedcookie@0.4.2(transitive)
- Removedcsstype@3.1.3(transitive)
- Removedhoist-non-react-statics@3.3.2(transitive)
- Removedjs-cookie@2.2.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@17.0.2(transitive)
- Removedreact-is@16.13.117.0.2(transitive)
- Removedreact-redux@7.2.9(transitive)
- Removedredux@4.2.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)