ReactVision / viro

ViroReact: The AR and VR library for React Native πŸ“³πŸ’™πŸ’›πŸ€πŸ’š

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple Viro3Dobject with same source, only the first model is loaded

Turtleted21 opened this issue Β· comments

Hi,
I must load 6 times the same glb model, so I have 1 source and I add dynamically 6 times the same Viro3Dobject, but only the first model is loaded.
Sometimes this bug appear only the first time react use viro, the second time, all models are loaded,
Bug appear only on android release, not in debug
(tested on galaxy tab S5 , S7 ipad pro, ipad mini)

it's a old bug viromedia/viro#699 but still here with ViroCommunity v2.21.0
possible fix : duplicate the source for each Viro3Dobject

Thanks

Hi,

Allow me to share how to handle your problem.
Viro version: viro-community-react-viro-2.22.1 <- NS-BOBBY-C version, the latest version still on progress so we give room to community to finish.

and under your code convert to React.PureComponent

export default class ArtItemRender extends React.PureComponent<IProps, IState>

please follow FigmentAR code in order to handle multiple Viro3DObject

Screen Shot 2022-06-25 at 00 18 16

Hi, I use const function not class, equivalent to React.PureComponent is React.memo?
https://dmitripavlutin.com/use-react-memo-wisely/

thanks

no difference, you cannot use React.memo, what you need just convert https://github.com/ViroCommunity/figment-ar/blob/main/js/model/PortalItems.js to modern typescript. Or leave like that file if you using .js

image

and how to use that component as following:

image

as the results you should have individual component without re-render while your parent rendering. if you use memo it will re-render (my case)

In my case, i only want render the new selected item. and data coming from redux. Previously I am using React.Memo but seems useless , so i just use direct embedded render