Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-context-api-store

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-context-api-store - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

43

lib/index.js

@@ -8,4 +8,2 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

@@ -85,14 +83,8 @@

function Provider() {
var _ref2;
var _temp2, _this2, _ret2;
function Provider(props) {
_classCallCheck(this, Provider);
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
var _this2 = _possibleConstructorReturn(this, (Provider.__proto__ || Object.getPrototypeOf(Provider)).call(this, props));
return _ret2 = (_temp2 = (_this2 = _possibleConstructorReturn(this, (_ref2 = Provider.__proto__ || Object.getPrototypeOf(Provider)).call.apply(_ref2, [this].concat(args))), _this2), _this2.state = _extends({}, _this2.props.store), _this2.persisted = false, _this2.persist = function () {
_this2.persist = function () {
if (_this2.props.persist !== false) {

@@ -102,3 +94,5 @@ _this2.props.persist.storage.removeItem(_this2.props.persist.key || 'react-context-api-store');

}
}, _this2.updateStore = function (updatedStore, callback) {
};
_this2.updateStore = function (updatedStore, callback) {
_this2.setState(_extends({}, _this2.state, updatedStore), function () {

@@ -108,3 +102,5 @@ _this2.persist();

});
}, _this2.render = function () {
};
_this2.render = function () {
return _react2.default.createElement(

@@ -120,16 +116,15 @@ StoreContext.Provider,

);
}, _temp2), _possibleConstructorReturn(_this2, _ret2);
}
};
_createClass(Provider, [{
key: 'componentDidMount',
value: function componentDidMount() {
if (this.props.persist !== false && !this.persisted) {
this.persisted = true;
var savedStore = this.props.persist.storage.getItem(this.props.persist.key || 'react-context-api-store');
if (_this2.props.persist !== false) {
var savedStore = _this2.props.persist.storage.getItem(_this2.props.persist.key || 'react-context-api-store');
this.updateStore(savedStore ? this.props.persist.statesToPersist(JSON.parse(savedStore)) : {});
}
_this2.state = _extends({}, _this2.props.store, _this2.props.persist.statesToPersist(JSON.parse(savedStore)));
_this2.persist();
} else {
_this2.state = _extends({}, _this2.props.store);
}
}]);
return _this2;
}

@@ -136,0 +131,0 @@ return Provider;

{
"name": "react-context-api-store",
"version": "1.0.13",
"description": "Seemless, lightweight, state management library that supports async actions and state persisting out of the box. Inspired by Redux and Vuex. Built on top of React's context api.",
"version": "1.0.14",
"description": "Seemless, lightweight, state management library that supports async actions and persistent states out of the box. Inspired by Redux and Vuex. Built on top of React's context api.",
"main": "lib/index.js",
"scripts": {
"test": "npm run build && jest --coverage --updateSnapshot",
"test": "clear && npm run build && jest --coverage --updateSnapshot",
"build": "rm -rf lib && babel src --out-dir lib && cp lib/index.js example/src/lib.js",

@@ -20,3 +20,4 @@ "lint": "eslint src/**/*.js __tests__/**/*.js"

"store",
"global-states"
"global-states",
"react"
],

@@ -43,3 +44,3 @@ "files": [

"babel-eslint": "^8.2.5",
"babel-jest": "^23.0.1",
"babel-jest": "^23.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",

@@ -52,4 +53,4 @@ "babel-plugin-transform-object-rest-spread": "^6.26.0",

"eslint": "^4.19.1",
"eslint-plugin-react": "^7.9.1",
"jest": "^23.1.0",
"eslint-plugin-react": "^7.10.0",
"jest": "^23.2.0",
"jest-localstorage-mock": "^2.2.0",

@@ -56,0 +57,0 @@ "react-dom": "^16.4.1",

@@ -5,6 +5,6 @@ # Repo status?

# react-context-api-store
Seemless, lightweight, state management library that supports async actions and state persisting out of the box. Inspired by Redux and Vuex. Built on top of [React's context api](https://reactjs.org/docs/context.html).
Seemless, lightweight, state management library that supports async actions and persistent states out of the box. Inspired by Redux and Vuex. Built on top of [React's context api](https://reactjs.org/docs/context.html).
# File size?
6.7kb transpiled. Not minified. Not compressed. Not uglified.
6.0kb transpiled. Not minified. Not compressed. Not uglified.

@@ -256,2 +256,6 @@ # Example

#### Callback on `store.updateStore`
`store.updateStore` has a second optional parameter which should be a `function` that will be run as callback of `setState`. This callback will receive the store's update state as it's only parameter. Please see [react's docs](https://reactjs.org/docs/react-component.html#setstate) about `setState`.
## How to handle async actions?

@@ -258,0 +262,0 @@

Sorry, the diff of this file is too big to display

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