Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
fix refId error when route changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abz53378 committed Jul 22, 2018
1 parent b7c9914 commit de27091
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions docs/canner.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import Users from './schema/realWorld/users.schema';
import Home from './schema/realWorld/home.schema';
import OnDeploy from './schema/onDeploy.schema';
import TabsFilter from './toolbar/filter';
// import utils from './utils';
// const {connector, storage, graphClient} = utils;
const connector = undefined;
const storage = undefined;
import utils from './utils';
const {connector, storage, graphClient} = utils;
// const connector = undefined;
// const storage = undefined;
const userColumns = [{
title: 'Name',
dataIndex: 'name'
Expand All @@ -31,7 +31,7 @@ const postColumns = [{
dataIndex: 'title'
}];

export default <root>
export default <root connector={connector}>
<object keyName="overview"
title="Components Overview"
storage={storage}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment-with-locales.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js" ></script>
<script src="https://cdn.canner.io/antd/3.6.6/antd.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/4.0.0-rc.9/immutable.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.1/immutable.min.js" ></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-app.js" ></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-auth.js" ></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-database.js" ></script>
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"@babel/preset-flow": "^7.0.0-beta.52",
"@babel/preset-react": "^7.0.0-beta.52",
"@babel/preset-stage-0": "^7.0.0-beta.52",
"babel-core": "^7.0.0-0",
"antd": "^3.2.3",
"babel-core": "^7.0.0-0",
"babel-eslint": "^8.2.2",
"babel-jest": "^23.2.0",
"babel-loader": "^8.0.0-beta",
Expand All @@ -57,6 +57,7 @@
"eslint-config-google": "^0.9.1",
"eslint-plugin-flowtype": "^2.46.1",
"eslint-plugin-react": "^7.7.0",
"firebase": "^4.13.1",
"flow-bin": "^0.66.0",
"flow-copy-source": "^1.3.0",
"graphql": "^0.13.2",
Expand All @@ -73,8 +74,7 @@
"style-loader": "^0.20.2",
"webpack": "^4.0.1",
"webpack-cli": "^2.0.10",
"webpack-dev-server": "^3.1.0",
"firebase": "^4.13.1"
"webpack-dev-server": "^3.1.0"
},
"dependencies": {
"@canner/antd-array-gallery": "0.2.5",
Expand Down Expand Up @@ -120,7 +120,7 @@
"canner-ref-id": "^0.1.2",
"graphql-tag": "^2.9.1",
"immer": "^1.3.0",
"immutable": "4.0.0-rc.9",
"immutable": "^3.8.2",
"invariant": "^2.2.4",
"lodash": "^4.17.5",
"lowdb": "^1.0.0",
Expand All @@ -134,11 +134,11 @@
"styled-components": "^3.2.1"
},
"peerDependencies": {
"antd": "^3.2.3",
"canner-graphql-interface": "^1.16.0",
"canner-helpers": "^0.1.15",
"react": ">=16.3",
"react-dom": ">=16.3",
"antd": "^3.2.3"
"react-dom": ">=16.3"
},
"jest": {
"moduleNameMapper": {
Expand Down
3 changes: 3 additions & 0 deletions src/hocs/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export default function connectId(Com: React.ComponentType<*>) {

if (pattern === 'array' && routes.length === 1 && this.args && this.props.routes.length > 1) {
// posts/<postId> => posts
this.setState({
refId: new RefId(`${keyName}`)
});
updateQuery([keyName], this.args);
delete this.args;
}
Expand Down
3 changes: 1 addition & 2 deletions src/hocs/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ export default function withQuery(Com: React.ComponentType<*>) {

UNSAFE_componentWillReceiveProps(props: Props) {
const {refId} = this.props;

if (refId.toString() !== props.refId.toString()) {
// refetch when route change
this.queryData(props);
}
}
}

componentWillUnmount() {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5646,7 +5646,7 @@ immutable@4.0.0-rc.9, immutable@^4.0.0-rc.9:
version "4.0.0-rc.9"
resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0-rc.9.tgz#1e6e0094e649013ec3742d2b5aeeca5eeda4f0bf"

immutable@^3.7.4:
immutable@^3.7.4, immutable@^3.8.2:
version "3.8.2"
resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3"

Expand Down

0 comments on commit de27091

Please sign in to comment.