Skip to content

React Docs for v7 do not work #428

@M1dnight-ofcl

Description

@M1dnight-ofcl

I followed the react docs for v7 of jsdos, although they did not work. Upon trying to boot using jsdos, im presented with the error CompileError: WebAssembly.compile(): expected magic word 00 61 73 6d, found 3c 21 64 6f @+0

It apears to be a wasm issue

Here is my code for refrence

//https://js-dos.com/v7/build/
//https://js-dos.com/v7/build/docs/react/

import { motion } from 'motion/react';
import React, { useEffect, useRef, useState, type ReactElement } from 'react';
import "./style.scss";
import { Helmet } from 'react-helmet-async';
import { DosPlayer as Instance, type DosPlayerFactoryType } from "js-dos";
//types
declare const Dos:DosPlayerFactoryType;
declare global{interface Window{Dosbox:Object|any;}}
interface DosPlayerProps{bundleUrl:string;}
interface IDosBoxComponent{path:string;}
//component
const DosPlayer=(props:DosPlayerProps):ReactElement=>{
  const rootRef=useRef<HTMLDivElement>(null);
  const[dos,setDos]=useState<Instance | null>(null);
  useEffect(()=>{
    if(rootRef===null||rootRef.current===null)return;
    const root=rootRef.current as HTMLDivElement;
    const instance=Dos(root);
    setDos(instance);
    return()=>{instance.stop();};
  },[rootRef]);
  useEffect(()=>{
    if(dos!==null)dos.run(props.bundleUrl);
  },[dos,props.bundleUrl]);
  return<div 
    ref={rootRef}
    style={{width:"100%",height:"100%"}}></div>;
};
const DosboxPage=({path}:IDosBoxComponent):ReactElement=>{
  return(<>
    <Helmet>
      <title>dosbox - {path}</title>
    </Helmet>
    <motion.div className='DosPageWrapper'>
      <p>{path}</p>
      <DosPlayer bundleUrl={path} />
    </motion.div>
  </>);
};
export default DosboxPage;

please help

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions