Socket
Socket
Sign inDemoInstall

@sanity/state-router

Package Overview
Dependencies
2
Maintainers
6
Versions
702
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.100.4 to 0.101.3

32

lib/components/RouterProvider.js

@@ -17,6 +17,2 @@ 'use strict';

var _assignLazyGetter = require('./assignLazyGetter');
var _assignLazyGetter2 = _interopRequireDefault(_assignLazyGetter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -87,26 +83,5 @@

value: function getChildContext() /*: RouterProviderContext*/ {
var _this2 = this;
var _warn = function warn() {
// eslint-disable-next-line no-console
console.error(new Error('Reading "router" from context is deprecated. Use the WithRouter enhancer/HOC, or the <WithRouter> component instead.'));
_warn = function warn() {};
return {
__internalRouter: this.__internalRouter
};
var deprecatedChildRouter = {};
(0, _assignLazyGetter2.default)(deprecatedChildRouter, 'state', function () {
_warn();
return _this2.getState();
});
(0, _assignLazyGetter2.default)(deprecatedChildRouter, 'navigate', function () {
_warn();
_this2.getState();
});
// todo: just return childContext with __internalRouter, remove the deprecatedChidlRouter eventually
var childContext = {
__internalRouter: this.__internalRouter,
router: deprecatedChildRouter
};
return childContext;
}

@@ -132,5 +107,4 @@ }, {

RouterProvider.childContextTypes = {
__internalRouter: _react.PropTypes.object,
router: _react.PropTypes.object
__internalRouter: _react.PropTypes.object
};
exports.default = RouterProvider;

46

lib/components/RouteScope.js

@@ -19,6 +19,2 @@ 'use strict';

var _assignLazyGetter = require('./assignLazyGetter');
var _assignLazyGetter2 = _interopRequireDefault(_assignLazyGetter);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -69,26 +65,5 @@

value: function getChildContext() /*: RouterProviderContext*/ {
var _this2 = this;
var _warn = function warn() {
// eslint-disable-next-line no-console
console.error(new Error('Reading "router" from context is deprecated. Use the WithRouter enhancer/HOC, or the <WithRouter> component instead.'));
_warn = function warn() {};
return {
__internalRouter: this.__internalRouter
};
var deprecatedChildRouter = {};
(0, _assignLazyGetter2.default)(deprecatedChildRouter, 'state', function () {
_warn();
return _this2.getScopedState();
});
(0, _assignLazyGetter2.default)(deprecatedChildRouter, 'navigate', function () {
_warn();
_this2.getScopedState();
});
// todo: just return childContext with __internalRouter, remove the deprecatedChidlRouter eventually
var childContext = {
__internalRouter: this.__internalRouter,
router: deprecatedChildRouter
};
return childContext;
}

@@ -106,13 +81,12 @@ }, {

RouteScope.childContextTypes = RouteScope.contextTypes = {
__internalRouter: _react.PropTypes.object,
router: _react.PropTypes.object
__internalRouter: _react.PropTypes.object
};
var _initialiseProps = function _initialiseProps() {
var _this3 = this;
var _this2 = this;
this.getScopedState = function () {
var scope = _this3.props.scope;
var scope = _this2.props.scope;
var parentInternalRouter = _this3.context.__internalRouter;
var parentInternalRouter = _this2.context.__internalRouter;
return parentInternalRouter.getState()[scope];

@@ -122,4 +96,4 @@ };

this.resolvePathFromState = function (nextState /*: Object*/) /*: string*/ {
var parentInternalRouter = _this3.context.__internalRouter;
var scope = _this3.props.scope;
var parentInternalRouter = _this2.context.__internalRouter;
var scope = _this2.props.scope;

@@ -132,4 +106,4 @@ var nextStateScoped /*: Object*/ = (0, _isEmpty2.default)(nextState) ? {} : addScope(parentInternalRouter.getState(), scope, nextState);

this.navigate = function (nextState /*: Object*/, options /*: NavigateOptions*/) /*: void*/ {
var parentInternalRouter = _this3.context.__internalRouter;
var nextScopedState = addScope(parentInternalRouter.getState(), _this3.props.scope, nextState);
var parentInternalRouter = _this2.context.__internalRouter;
var nextScopedState = addScope(parentInternalRouter.getState(), _this2.props.scope, nextState);
parentInternalRouter.navigate(nextScopedState, options);

@@ -136,0 +110,0 @@ };

{
"name": "@sanity/state-router",
"version": "0.100.4",
"version": "0.101.3",
"description": "A path pattern => state object bidirectional mapper",

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

@@ -6,3 +6,2 @@ // @flow

import pubsub from 'nano-pubsub'
import assignLazyGetter from './assignLazyGetter'

@@ -20,4 +19,3 @@ type Props = {

static childContextTypes = {
__internalRouter: PropTypes.object,
router: PropTypes.object
__internalRouter: PropTypes.object
}

@@ -40,2 +38,3 @@

}
navigateUrl = (url : string, options : NavigateOptions = {}) : void => {

@@ -61,27 +60,5 @@ const {onNavigate} = this.props

getChildContext() : RouterProviderContext {
let warn = () => {
// eslint-disable-next-line no-console
console.error(new Error(
'Reading "router" from context is deprecated. Use the WithRouter enhancer/HOC, or the <WithRouter> component instead.'
))
warn = () => {}
return {
__internalRouter: this.__internalRouter
}
const deprecatedChildRouter = {}
assignLazyGetter(deprecatedChildRouter, 'state', () => {
warn()
return this.getState()
})
assignLazyGetter(deprecatedChildRouter, 'navigate', () => {
warn()
this.getState()
})
// todo: just return childContext with __internalRouter, remove the deprecatedChidlRouter eventually
const childContext = {
__internalRouter: this.__internalRouter,
router: deprecatedChildRouter
}
return childContext
}

@@ -88,0 +65,0 @@

// @flow
import React, {PropTypes, Element} from 'react'
import isEmpty from '../utils/isEmpty'
import assignLazyGetter from './assignLazyGetter'

@@ -25,4 +24,3 @@ import type {RouterProviderContext, NavigateOptions, InternalRouter} from './types'

static childContextTypes = RouteScope.contextTypes = {
__internalRouter: PropTypes.object,
router: PropTypes.object
__internalRouter: PropTypes.object
}

@@ -43,27 +41,5 @@

getChildContext() : RouterProviderContext {
let warn = () => {
// eslint-disable-next-line no-console
console.error(new Error(
'Reading "router" from context is deprecated. Use the WithRouter enhancer/HOC, or the <WithRouter> component instead.'
))
warn = () => {}
return {
__internalRouter: this.__internalRouter
}
const deprecatedChildRouter = {}
assignLazyGetter(deprecatedChildRouter, 'state', () => {
warn()
return this.getScopedState()
})
assignLazyGetter(deprecatedChildRouter, 'navigate', () => {
warn()
this.getScopedState()
})
// todo: just return childContext with __internalRouter, remove the deprecatedChidlRouter eventually
const childContext = {
__internalRouter: this.__internalRouter,
router: deprecatedChildRouter
}
return childContext
}

@@ -70,0 +46,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc