mercredi 18 novembre 2020

Unwanted two-way data binding when passing data to Ember Octane component

I'm following the Full Stack Ember with Rails course on Embercasts. As they don't use Octane yet, I change the code where necessary to work with Ember 3.22. I'm stuck in video 22 where I need to pass data to a component. This data should only be passed to the component, but when updating a value inside it, I don't want to see the change in other places.

In the video, this is taken care of in a didReceiveAttrs() handler, but this is not available in Octane. Instead, the Ember docs describe one way data flow as what happens automatically. In my case, it doesn't:



<h3>Editing: ,  </h3>
<AuthorForm @autor= />



<div class="field">
  <label for="first">First name</label>
  <Input @id="first" type="text" placeholder="First name" @value=/>
</div>  

<div class="field">
  <label for="last">Last name</label>
  <Input @id="last" type="text" placeholder="Last name" @value=/>
</div>

The h3 updates whenever I change the value in one of the component's inputs. What's wrong here?




Aucun commentaire:

Enregistrer un commentaire