top of page
Logo der Online Agentur mdwp

Use Strict

"Use Strict" is not specifically a React JS term but rather a general JavaScript directive that is used to enable strict mode in the script. When you add 'use strict'; at the start of a script, it enables strict mode and helps you write cleaner code.

In strict mode, JavaScript has higher requirements for code syntax, helps you catch errors earlier and prevents the use of some unsafe language features. For example, undeclared variables are not allowed, deleting variables, functions or function parameters is not allowed, octal numeric literals are not allowed and more.

It is generally recommended to use 'use strict'; in your JavaScript files, including in React components.

Here is an example of what using 'use strict'; looks like:

```JS
'use strict';

class App extends React.Component {
render() {
// code...
return (
// JSX...
)
}
}

```

In this example, 'use strict'; is added at the top of the file to enable strict mode. This will ensure that the rest of the JavaScript code in this file follows the stricter, more rigorous rules.

bottom of page