diff --git a/src/components/nitropedia/NitropediaView.tsx b/src/components/nitropedia/NitropediaView.tsx index 2c2d7b0d..45fd167f 100644 --- a/src/components/nitropedia/NitropediaView.tsx +++ b/src/components/nitropedia/NitropediaView.tsx @@ -10,7 +10,7 @@ export const NitropediaView: FC<{}> = props => { const [ content, setContent ] = useState(null); const [ header, setHeader] = useState(''); - const [wH, setWH] = useState<{w:number,h:number}>({ w:0, h:0 }); + const [ dimensions, setDimensions ] = useState<{ width: number, height: number}>(null); const elementRef = useRef(null); const openPage = useCallback(async (link: string) => @@ -22,19 +22,26 @@ export const NitropediaView: FC<{}> = props => if(!response) return; const text = await response.text(); - const splitData = text.split(NEW_LINE_REGEX); + const line = splitData.shift().split('|'); - setWH({ w: 0, h: 0 }); - BatchUpdates(() => { - let line = splitData.shift().split('|'); setHeader(line[0]); - if(line[1] && line[1].split(';').length === 2) - setWH({ w: parseInt(line[1].split(';')[0]), h: parseInt(line[1].split(';')[1]) }); - + setDimensions(prevValue => + { + if(line[1] && (line[1].split(';').length === 2)) + { + return { + width: parseInt(line[1].split(';')[0]), + height: parseInt(line[1].split(';')[1]) + } + } + + return null; + }); + setContent(splitData.join('')); }); } @@ -91,8 +98,8 @@ export const NitropediaView: FC<{}> = props => if(!content) return null; return ( - - setContent(null)}/> + + setContent(null) }/>