Render on demand with render
function
#2095
Answered
by
CodyJasonBennett
TiagoCavalcante
asked this question in
Q&A
-
I'm working on a project where we can't use Canvas because we need it to have different behavior on window resizes, and some other custom CSS stuff. How can I "enable" the The render function seems to have the frame loop |
Beta Was this translation helpful? Give feedback.
Answered by
CodyJasonBennett
Feb 25, 2022
Replies: 1 comment
-
import React from 'react'
import { render, events } from '@react-three/fiber'
window.addEventListener('resize', () =>
render(<mesh />, document.querySelector('canvas'), {
events,
size: { width: window.innerWidth, height: window.innerHeight },
frameloop: 'demand',
}),
)
window.dispatchEvent(new Event('resize')) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TiagoCavalcante
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
render
accepts the same render props as canvas, so you can passframeloop: 'demand'
as follows: