Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I hope to be able to add callback functions, such as mount and update. #6

Open
Mrcxt opened this issue Feb 27, 2024 · 1 comment
Open

Comments

@Mrcxt
Copy link

Mrcxt commented Feb 27, 2024

I need to do something after the iframe has finished loading, and I need to use callback functions.

jaywcjlove added a commit that referenced this issue Feb 29, 2024
jaywcjlove added a commit that referenced this issue Feb 29, 2024
github-actions bot pushed a commit that referenced this issue Feb 29, 2024
@jaywcjlove
Copy link
Member

@Mrcxt

import React, { useEffect, useState, Fragment } from 'react';
import IFrame, { useFrame } from '@uiw/react-iframe';

const InnerComponent = () => {
  // Hook returns iframe's window and document instances from Frame context
  const { document, window } = useFrame();
  return (
    <div>
      <div>Hello World!</div>
    </div>
  );
};

export default function Demo() {
  const onLoad = (evn) => {
    console.log("iframe loaded successfully!", evn)
  }
  return (
    <IFrame onLoad={onLoad}>
      <InnerComponent />
    </IFrame>
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants