I'm working on a ruby on rails application with a react js frontend.
What does the @ signify here
import ProductCard from '@components/search/ProductCard';
Symbols are unique data types and no two Symbols are never equal. This feature opens up one of many possibilities of using them in React applications to run code in child components by passing them as props.
Inline If with Logical && Operator It works because in JavaScript, true && expression always evaluates to expression , and false && expression always evaluates to false . Therefore, if the condition is true , the element right after && will appear in the output. If it is false , React will ignore and skip it.
"this" is the keyword, which holds reference to something, in this case, this is used within a class naming Foo, so when we use the keyword "this" inside the class it refers to class itself.
Import an entire module's contents This inserts myModule into the current scope, containing all the exports from the module in the file located in /modules/my-module.
If you are using Typescript (which the tag suggests you are) it's possible to setup "path mapping" in your tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@": ["./src"],
"@/*": ["./src/*"],
"@components": ["./src/components"]
}
}
}
This will create an alias for "@components" that points to a specific folder.
Read more about it here: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
It could be a scoped package like @types/xxx
but this is unlikely in the given case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With