I want to render a standlone html js project (game project) inside a react component.
standlone html js project portion code:
react component
export default function Tetris() {
function iframe() {
return {
__html:
'<iframe src="../../../Standlone Games/Tetris/index.html" width="540" height="450"></iframe>',
};
}
return (
<div>
<div dangerouslySetInnerHTML={iframe()} />
</div>
);
}
I have tried using dangerouslySetInnerHTML & iframe , but i receive a 404 (Not Found) error and an empty frame !
while the path is 100% correct!
2
Answers
Thans to Mr. Polywhirl's idea , i just replaced the path to the absolute path and it works fine! Solution:
Why not render a native
<iframe>
element in the component?