@@ -5,6 +5,7 @@ import { Card, Input, Typography, ConfigProvider, theme } from 'antd'
55import GitHubButton , { ReactGitHubButtonProps } from 'react-github-btn'
66import ReactGA from 'react-ga'
77import createPersistedState from 'use-persisted-state'
8+ import queryString from 'query-string'
89import VersionSelector from '../common/VersionSelector'
910import DiffViewer from '../common/DiffViewer'
1011import Settings from '../common/Settings'
@@ -107,6 +108,19 @@ const SettingsContainer = styled.div`
107108 flex: 1;
108109`
109110
111+ const getAppInfoInURL = ( ) : {
112+ appPackage : string
113+ appName : string
114+ } => {
115+ // Parses `/?name=RnDiffApp&package=com.rndiffapp` from URL
116+ const { name, package : pkg } = queryString . parse ( window . location . search )
117+
118+ return {
119+ appPackage : pkg as string ,
120+ appName : name as string ,
121+ }
122+ }
123+
110124interface StarButtonProps extends ReactGitHubButtonProps {
111125 className ?: string
112126}
@@ -138,8 +152,9 @@ const Home = () => {
138152 [ `${ SHOW_LATEST_RCS } ` ] : false ,
139153 } )
140154
141- const [ appName , setAppName ] = useState < string > ( '' )
142- const [ appPackage , setAppPackage ] = useState < string > ( '' )
155+ const appInfoInURL = getAppInfoInURL ( )
156+ const [ appName , setAppName ] = useState < string > ( appInfoInURL . appName )
157+ const [ appPackage , setAppPackage ] = useState < string > ( appInfoInURL . appPackage )
143158
144159 // Avoid UI lag when typing.
145160 const deferredAppName = useDeferredValue ( appName )
@@ -303,6 +318,8 @@ const Home = () => {
303318 packageName = { packageName }
304319 language = { language }
305320 isPackageNameDefinedInURL = { isPackageNameDefinedInURL }
321+ appPackage = { appPackage }
322+ appName = { appName }
306323 />
307324 </ Container >
308325 { /*
0 commit comments