I am going to give you information about arrays, decleration of arrays, methods and properties of arrays.
Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations. Neither the length of a JavaScript array nor the types of its elements are fixed. Since an array’s length can change at any time, and data can be stored at non-contiguous locations in the array, JavaScript arrays are not guaranteed to be dense; this depends on how the programmer chooses to use them. …
Bu problemin baş verməsinin səbəbi React.StrictMode-un bir xüsusiyyətidir. Əslində bu sadəcə development mode-da baş verir və əsas məqsədi isə render mərhələsində baş verə biləcək yan təsirlərin qarşısının alınmasıdır.
Fərqli misallar üzərində bunu müşahidə etmək mümkündür.
A) useState ilə yazılmış functional component-ə nəzər salaq.
function App() {
const [click, setClick] = React.useState(0);console.log('Render edildi ', click);
return (
<div>
<button onClick={() => setClick(click => click + 1)}>
Clicks: {click}
</button>
</div>
)
}
Əgər create-react-app istifadə edərək react app yaratsaq və npm start ilə çalışdırsaq browser console-da aşağıdakı output-la qarşılaşacağıq.
Render edildi 0
Render edildi 0
Əgər button-a bir dəfə click-ləsək belə…
Frontend Web Devloper, Founder and Editor of Star Gazers