diff --git a/src/factory.tsx b/src/factory.tsx index 6179f0e1..beea270b 100644 --- a/src/factory.tsx +++ b/src/factory.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import * as PropTypes from 'prop-types'; +import * as qs from 'qs'; import { RendererStore, IRendererStore, @@ -277,10 +277,21 @@ export class RootRenderer extends React.Component { rootStore, env, pathPrefix, + location, + data, ...rest } = this.props; const theme = env.theme; + const query = location && location.query + || location && location.search && qs.parse(location.search.substring(1)) + || window.location.search && qs.parse(window.location.search.substring(1)); + + const finalData = query ? { + ...data, + ...query, + query + } : data; return ( @@ -290,6 +301,7 @@ export class RootRenderer extends React.Component { ...(schema as Schema) } : schema, { ...rest, + data: finalData, env, classnames: theme.classnames, classPrefix: theme.classPrefix diff --git a/src/renderers/Page.tsx b/src/renderers/Page.tsx index cfd9d7c8..7a52cf5d 100644 --- a/src/renderers/Page.tsx +++ b/src/renderers/Page.tsx @@ -89,21 +89,21 @@ export default class Page extends React.Component { 'initInterval', ]); - if (location && location.search) { - const query = location.query || qs.parse(location.search.substring(1)); + // if (location && location.search) { + // const query = location.query || qs.parse(location.search.substring(1)); - store.reInitData({ - ...query, - query: query, - }); - } else if (!location && window.location.search) { - const query = qs.parse(window.location.search.substring(1)); + // store.reInitData({ + // ...query, + // query: query, + // }); + // } else if (!location && window.location.search) { + // const query = qs.parse(window.location.search.substring(1)); - store.reInitData({ - ...query, - query: query, - }); - } + // store.reInitData({ + // ...query, + // query: query, + // }); + // } } componentDidMount() { @@ -129,16 +129,16 @@ export default class Page extends React.Component { const props = this.props; const store = props.store; - if (nextProps.location && (!props.location || props.location.search !== nextProps.location.search)) { - const query = - nextProps.location.query || - (nextProps.location.search && qs.parse(nextProps.location.search.substring(1))) || - {}; - store.updateData({ - ...query, - query: query, - }); - } + // if (nextProps.location && (!props.location || props.location.search !== nextProps.location.search)) { + // const query = + // nextProps.location.query || + // (nextProps.location.search && qs.parse(nextProps.location.search.substring(1))) || + // {}; + // store.updateData({ + // ...query, + // query: query, + // }); + // } } componentDidUpdate(prevProps: PageProps) {