Rescreva essa parte da string com as seguintes condições: 1. Não elimine NENHUMA…
- User
Rescreva essa parte da string com as seguintes condições: 1. Não elimine NENHUMA informação dada no artigo. 2. Conceitos, termos ou referências devem ser mantidas em inglês. 3. Apenas transcreva o artigo para um inglês simples, sem alterar o contexto. 4. Não remova as tags HTML e nem os "#thedivisor#". 5. Você deve me enviar sua resposta em texto puro, sem markdown.
#thedivisor#We will be using <code>props</code> here, and you will learn more about them in the next lesson. For now, you just need to know that <code>props</code> are arguments that are passed into components.#thedivisor#Keys are passed into the component or a DOM element as a prop. You should already be familiar with the syntax.#thedivisor#<span id="keys-from-data">Now that we know the syntax, the next question is: what should be used as a key? Ideally, they should be some identifier that is unique to each item in the list. Most databases assign a unique id to each entry, so you shouldn’t have to worry about assigning an id yourself. If you are defining data yourself, it is good practice to assign a unique <code>id</code> to each item. You can use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID" target="_blank" rel="noopener noreferrer">crypto.randomUUID() function</a> to generate a unique id. Let’s look at an example:</span>#thedivisor#<span id="index-as-key">Additionally, if you’re sure the list will remain unchanged throughout the application’s life, you can use the array index as a key. However, this is not recommended since it can lead to confusing bugs if the list changes when items are deleted, inserted, or rearranged. You will learn more about this in the assignment section’s linked article.</span>#thedivisor#<span id="anti-pattern">Keys are straightforward to use, though there is an anti-pattern you should be aware of. Keys should never be generated on the fly. Using <code>key={Math.random()}</code> or <code>key={crypto.randomUUID()}</code> <em>while</em> rendering the list defeats the purpose of the key, as now a new <code>key</code> will get created for every render of the list. As shown in the above example, <code>key</code> should be inferred from the data itself.</span> - Assistant
#thedivisor#We will be using props here, and you will learn more about them in the next lesson. For now, you just need to know that props are arguments that are passed into components.#thedivisor#Keys are passed into the component or a DOM element as a prop. You should already know the syntax.#thedivisor#Now that we know the syntax, the next question is: what should be used as a key? Ideally, they should be some identifier that is unique to each item in the list. Most databases give a unique id to each entry, so you shouldn’t have to worry about giving an id yourself. If you are making data yourself, it is good practice to give a unique id to each item. You can use the crypto.randomUUID() function to create a unique id. Let’s look at an example:#thedivisor#Also, if you are sure the list will stay the same throughout the application’s life, you can use the array index as a key. However, this is not recommended because it can lead to confusing bugs if the list changes when items are deleted, added, or rearranged. You will learn more about this in the linked article in the assignment section.#thedivisor#Keys are easy to use, but there is an anti-pattern you should know about. Keys should never be created on the fly. Using key={Math.random()} or key={crypto.randomUUID()} while rendering the list defeats the purpose of the key, as now a new key will be created for every render of the list. As shown in the example above, key should be based on the data itself.