Closed Algorush closed 3 weeks ago
Is this fixing #577 too? That's really not a good idea to update a DOM element that is handled by React. Can't we use an effect in SceneEditTitle to listen to the newTitle event?
Can't we use an effect in SceneEditTitle to listen to the newTitle event?
But we are loading json-utils.js before the Editor code which contains Events.
I don't understand a little how this can be implemented. Now if I import 'editor/lib/Events' into SceneEditTitle.component
, where I assign Events.on('newtitle' ()=> ...)
. And I also import Events
into json-utils.js. But since json-utils is called earlier, Events is imported with an empty list of events.
Also I noticed that now when loading a saved scene with title, initially title=Undefined. But after selecting any entity, its title appears, this is not clear to me. This happens even without calling the 'newtitle' event handler
Events.js on
and emit
functions is used only for parts of editor between aframe world and React. The newTitle
event emitted in the metadata
aframe component is not using that but the emit
function from aframe entity. That's not the same. To register a listener for that event you need to use AFRAME.scenes[0].addEventListener('newTitle', ...)
.
If you see at one point the title when you select an entity, probably the SceneEditTitle react component is rerendering, you can check what going on with the props and the effect there.
Events.js
on
andemit
functions is used only for parts of editor between aframe world and React. ThenewTitle
event emitted in themetadata
aframe component is not using that but theemit
function from aframe entity. That's not the same. To register a listener for that event you need to useAFRAME.scenes[0].addEventListener('newTitle', ...)
.
Thanks for this tip. I didn’t realize at first that I could use an existing event
Issue: https://github.com/3DStreet/3dstreet/issues/553 Now the title is saved in JSON and also updated in Editor mode. But there is another error related to Firebase - https://github.com/3DStreet/3dstreet/issues/532. I will fix it in another branch.