🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

redux-router-middleware

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-router-middleware - npm Package Compare versions

Comparing version

to
1.0.0-beta.16

@@ -48,3 +48,2 @@ 'use strict';

value: function componentDidMount() {
if (!this.props.isAuthenticate && this.props.isMatch) {

@@ -57,3 +56,2 @@ this.props.replace(this.props.redirect);

value: function componentDidUpdate(prevProps, prevState) {
if (!this.props.isAuthenticate && this.props.isMatch) {

@@ -69,10 +67,24 @@ this.props.replace(this.props.redirect);

exports.Match = Match = (0, _reactRedux.connect)(function (state, props) {
var url = state.routing.urls[props.name];
if (url) return {
isMatch: props.isExactly && url.match == 2 || !props.isExactly && url.match,
var isMatch;
if (Array.isArray(props.name)) {
var names = props.name;
isMatch = names.some(function (name) {
var url = state.routing.urls[name];
if (url) {
return props.isExactly && url.match == 2 || !props.isExactly && url.match;
}
return false;
});
} else {
var url = state.routing.urls[props.name];
if (url) {
isMatch = props.isExactly && url.match == 2 || !props.isExactly && url.match;
} else {
isMatch = false;
}
}
return {
isMatch: isMatch,
isAuthenticate: props.checkAuthenticate ? props.checkAuthenticate(state) : true
};
return {
isMatch: 0
};
}, { replace: _actions.replace })(Match);

@@ -79,0 +91,0 @@

{
"name": "redux-router-middleware",
"version": "1.0.0-beta.15",
"version": "1.0.0-beta.16",
"description": "",
"main": "lib/index",
"repository": {
"repository": {
"type": "git",

@@ -17,27 +17,17 @@ "url": "git+https://github.com/vimalceg/redux-router-middleware.git"

"scripts": {
"clean":"fz-react-cli clean lib coverage",
"clean": "fz-react-cli clean lib coverage",
"build:umd": "npm run clean && fz-react-cli build:component:umd",
"build":"npm run clean && fz-react-cli build:component",
"build": "npm run clean && fz-react-cli build:component",
"prepublish": "npm run build",
"start": "webpack public/js/ReactRouterRedux.js && node server.js",
"example":"webpack public/js/ReactRouterRedux.js --watch"
"example": "webpack public/js/ReactRouterRedux.js --watch"
},
"tags": [
"react",
"redux"
],
"keywords": [
"react",
"redux",
"router"
],
"tags": ["react", "redux"],
"keywords": ["react", "redux", "router"],
"devDependencies": {
"fz-react-cli":"0.0.3-beta.31"
"fz-react-cli": "0.0.3-beta.31"
},
"babel": {
"presets": [
"es2015",
"react"
]
"presets": ["es2015", "react"]
}
}
# react-router-redux
##Just my thought.
##Just my thought.
1. History object is a side-effect. If you are using redux then handle history object inside middleware. Don't flow over component. In react-router, histroy object flow over component via context. All Link(withRouter) component more couple with router. It breaks some reusablity.
2. Connect(React-Redux) has subscriber model for state changes UI changes. If we sync URL state into app state then we may use same connect component for URL changes also.
2. Connect(React-Redux) has subscriber model for state changes UI changes. If we sync URL state into app state then we may use same connect component for URL changes also.
I tried some example
I tried some example

@@ -14,1 +14,4 @@ ```

```
# 1.0.0-beta.16
Match - props support array name={['page1','page2']}
import React from 'react';
import { connect } from 'react-redux';
import { replace } from '../actions'
export class Match extends React.Component{
render(){
import { replace } from '../actions';
export class Match extends React.Component {
render() {
var { children, isMatch, isAuthenticate } = this.props;
return isMatch && isAuthenticate && React.Children.only(children) || null;
return (isMatch && isAuthenticate && React.Children.only(children)) || null;
}
componentDidMount() {
if(!this.props.isAuthenticate && this.props.isMatch){
this.props.replace(this.props.redirect)
if (!this.props.isAuthenticate && this.props.isMatch) {
this.props.replace(this.props.redirect);
}
}
componentDidUpdate(prevProps, prevState) {
if(!this.props.isAuthenticate && this.props.isMatch){
this.props.replace(this.props.redirect)
if (!this.props.isAuthenticate && this.props.isMatch) {
this.props.replace(this.props.redirect);
}

@@ -24,16 +21,39 @@ }

Match = connect((state,props)=>{
var url =state.routing.urls[props.name];
if(url)
return {
isMatch: (props.isExactly && url.match == 2) || (!props.isExactly && url.match),
isAuthenticate: props.checkAuthenticate? props.checkAuthenticate(state) : true
}
return {
isMatch:0
}
},{replace})(Match)
Match = connect(
(state, props) => {
var isMatch;
if (Array.isArray(props.name)) {
var names = props.name;
isMatch = names.some(name => {
var url = state.routing.urls[name];
if (url) {
return (
(props.isExactly && url.match == 2) ||
(!props.isExactly && url.match)
);
}
return false;
});
} else {
var url = state.routing.urls[props.name];
if (url) {
isMatch =
(props.isExactly && url.match == 2) ||
(!props.isExactly && url.match);
} else {
isMatch = false;
}
}
return {
isMatch,
isAuthenticate: props.checkAuthenticate
? props.checkAuthenticate(state)
: true
};
},
{ replace }
)(Match);
Match.defaultProps={
isExactly:false
}
Match.defaultProps = {
isExactly: false
};