apple2js/js/components/Slinky.tsx
Will Scullin e525e12c3c
React linters (#117)
* React hook linter

* React linting

* Simplify config
2022-05-29 13:48:51 -07:00

31 lines
687 B
TypeScript

import { useEffect } from 'preact/hooks';
import Apple2IO, { slot } from '../apple2io';
import RAMFactor from '../cards/ramfactor';
/**
* Slinky component properties
*/
export interface SlinkyProps {
io: Apple2IO | undefined;
slot: slot;
}
/**
* RAMFactory (Slinky) memory card component. Adds
* 1MB of slinky compatible memory.
*
* @param io Apple2IO object
* @param slot Slot to register card in
* @returns Slinky component
*/
export const Slinky = ({ io, slot }: SlinkyProps) => {
useEffect(() => {
if (io) {
const slinky = new RAMFactor(1024 * 1024);
io.setSlot(slot, slinky);
}
}, [io, slot]);
return null;
};