Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint react/no-danger: 0 */
import React from 'react';
import ReactDOM from 'react-dom';
import WhiteSpace from 'antd-mobile/lib/white-space';
import 'antd-mobile/lib/white-space/style';
import Button from 'antd-mobile/lib/button';
import 'antd-mobile/lib/button/style';
import WingBlank from 'antd-mobile/lib/wing-blank';
import 'antd-mobile/lib/wing-blank/style';
import NoticeBar from 'antd-mobile/lib/notice-bar';
import 'antd-mobile/lib/notice-bar/style';
import collect from 'bisheng/collect';
import { getQuery } from '../../../../utils';
@collect(async (nextProps) => {
const { pathname } = nextProps.location;
const pageDataPath = pathname.replace('-cn', '').split('/');
const pageData = nextProps.utils.get(nextProps.data, pageDataPath);
if (!pageData) {
throw 404; // eslint-disable-line no-throw-literal
}
const locale = getQuery('lang') || 'en-US';
const pageDataPromise = typeof pageData === 'function' ?
pageData() : (pageData[locale] || pageData.index[locale] || pageData.index)();
const demosFetcher = nextProps.utils.get(nextProps.data, ['components', nextProps.params.component, 'demo']);
if (demosFetcher) {
const [localizedPageData, demos] = await Promise.all([pageDataPromise, demosFetcher()]);
return { localizedPageData, demos, locale };
}