ReactVision / viro

ViroReact: The AR and VR library for React Native 📳💙💛🤍💚
MIT License
1.42k stars 166 forks source link

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

Open Turtleted21 opened 2 years ago

Turtleted21 commented 2 years ago

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 https://github.com/viromedia/viro/issues/699 but still here with ViroCommunity v2.21.0 possible fix : duplicate the source for each Viro3Dobject

Thanks

tjikaljedy commented 2 years ago

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
Turtleted21 commented 2 years ago

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

thanks

tjikaljedy commented 2 years ago

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