'This' in react  {strict mode} vs {without strict} ??

'This' in react {strict mode} vs {without strict} ??

this in different places

When you call createRoot(document.getElementById("root")).render(...), the callback function you pass to render runs in a different context. Here, this is not tied to a specific object, so it defaults to undefined in strict mode.

In non-strict mode, this would default to the global object (usually the window object in a browser), but in strict mode, it defaults to undefined.

function outer() { console.log(this); // window (or global object)

function inner() { console.log(this); // window (or global object) }

inner(); }

outer();

// vs.

function outer() { "use strict"; console.log(this); // undefined

function inner() { console.log(this); // undefined }

inner(); }

outer();