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
<Image/> component #29
Comments
Maybe |
Good point! Let's also make an IFrame component then. Can you try if this <IFrame> component solves your problem? import {useCallback, useState} from 'react';
import {continueRender, delayRender} from 'remotion';
export const IFrame: React.FC<Omit<
React.DetailedHTMLProps<
React.IframeHTMLAttributes<HTMLIFrameElement>,
HTMLIFrameElement
>,
'onLoad'
>> = (props) => {
const [handle] = useState(() => delayRender());
const onLoad = useCallback(() => {
continueRender(handle);
}, [handle]);
return <iframe {...props} onLoad={onLoad} />;
}; I'll then add it to Remotion Core, add documentation and improve DX by adding an ESLint Rule to the Remotion plugin! |
Awesome, that fixed the iframe flickering, thanks! For other cases, maybe you can hide the function useResumer() {
const [handle] = useState(() => delayRender());
const resumeRender = useCallback(() => {
continueRender(handle);
}, [handle]);
return resumeRender;
} or something like that. |
Hey @JonnyBurger awesome project! I think that suspense can help with this issue! We can create custom import {continueRender, delayRender} from 'remotion';
class VideoSuspense extends Component {
constructor () {
this.state = {
loading: false
}
}
componentDidCatch(promise) {
if (isPromise(promise)) {
this.setState({ loading: true })
delayRender()
promise.then(() => {
this.setState({ loading: true })
continueRender()
})
} else {
throw promise
}
}
render () {
return this.state.loading ? null : this.props.children
}
}
// root
<VideoSuspense>
<Video/>
</VideoSuspense> it should be better, because we don't need to wrap components that already support suspense with remotion what do you think about that? I can help with implementation |
@jeetiss If that is possible using Suspense, then that's definitely preferrable! But how does it work? Where does that promise come from? How do we hook into the |
Since a lot of people are affected, I am going ahead with the original plan and will merge #32. There is now also an ESLint rule enabled which will warn you if you use the native or <iframe> component! |
Fixed by #32 |
@JonnyBurger, yes ofc! i am going to open new issue for suspense
I'm not the best explainer) super simple scheme:
Components throw them:
Iframe component is not so trivial for suspense, but can be implemented with hacks: Suspense is still experimental, but react community have a lot components that supports this feature |
Using normal HTML tags has the disadvantage that the image might not yet be loaded when Remotion is ready. I am thinking of adding a simple component which will hook into the onLoad event and wait for all images to be loaded using delayRender.
You can subscribe to this issue to follow the progress.
Solution for now:
The text was updated successfully, but these errors were encountered: