Skip to content

Commit

Permalink
feat(web): 增加测试开发用显示容器DevContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Dec 2, 2019
1 parent ee54dfd commit 48f02aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/src/components/DevContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useEffect, PropsWithChildren, Fragment } from 'react';
import React, { useState, useEffect, Fragment } from 'react';
import rnStorage from '@src/shared/api/rn-storage.api';

// 仅对内测用户显示
const DevContainer = (props: PropsWithChildren<{}>): React.ReactElement => {
const DevContainer: React.FC = (props) => {
const [isAlphaUser, setIsAlphaUser] = useState<boolean>(false);

useEffect(() => {
Expand Down
16 changes: 16 additions & 0 deletions src/web/components/DevContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { Fragment } from 'react';
import memoizeOne from 'memoize-one';

/**
* 获取是否为测试用户
* 方法是在localStorage上设置 trpg_test: true
*/
const checkIsTestUser = memoizeOne(() => {
return localStorage.getItem('trpg_test') === 'true';
});

const DevContainer: React.FC<{}> = React.memo((props) => {
return checkIsTestUser() ? <Fragment>{props.children}</Fragment> : null;
});

export default DevContainer;

0 comments on commit 48f02aa

Please sign in to comment.