Translate Components and Props page #10
base: main
Are you sure you want to change the base?
Translate Components and Props page #10
Conversation
Deploy preview for sv-reactjs ready! Built with commit 767288b |
content/docs/components-and-props.md
Outdated
|
||
## Function and Class Components {#function-and-class-components} | ||
## Funktion och klasskomponenter {#function-and-class-components} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say this is more fitting as Funktion- och klasskomponenter
, see https://sv.wikipedia.org/wiki/Berg-_och_dalbana
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rloqvist Fixing. 👍
content/docs/components-and-props.md
Outdated
} | ||
``` | ||
|
||
This function is a valid React component because it accepts a single "props" (which stands for properties) object argument with data and returns a React element. We call such components "function components" because they are literally JavaScript functions. | ||
Denna funktion är en giltig Reakt-komponent eftersom den accepterar en enda "props" (som står för properties) objektargument med data och returnerar ett React-element. Vi kallar sådana komponenter "funktionskomponenter" eftersom de bokstavligen är JavaScript-funktioner. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reakt
-> React
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rloqvist Fixing. 👍
content/docs/components-and-props.md
Outdated
} | ||
} | ||
``` | ||
|
||
The above two components are equivalent from React's point of view. | ||
De två ovannämnda komponenterna är identiska ur Reacts synvinkel. | ||
|
||
Classes have some additional features that we will discuss in the [next sections](/docs/state-and-lifecycle.html). Until then, we will use function components for their conciseness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rloqvist Fixing. 👍
content/docs/components-and-props.md
Outdated
|
||
Classes have some additional features that we will discuss in the [next sections](/docs/state-and-lifecycle.html). Until then, we will use function components for their conciseness. | ||
|
||
## Rendering a Component {#rendering-a-component} | ||
Klasser har några ytterligare funktioner, som vi kommer att diskutera i [nästa avsnitt](/docs/state-and-lifecycle.html). Fram till dess kommer vi att använda för funktionskomponenter för deras tydlighet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next sections
are plural and therefore I think senare avsnitt
would be a better fit here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rloqvist Fixing. 👍
content/docs/components-and-props.md
Outdated
3. Our `Welcome` component returns a `<h1>Hello, Sara</h1>` element as the result. | ||
4. React DOM efficiently updates the DOM to match `<h1>Hello, Sara</h1>`. | ||
1. Vi kallar `ReactDOM.render()` med React-elementet `<Welcome name="Sarah" />`. | ||
2. React anropar `Welcome` komponenten med `{name: 'Sara'}` som dess "props". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"props" doesn't need quotes here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rloqvist Fixing. 👍
content/docs/components-and-props.md
Outdated
|
||
This component can be tricky to change because of all the nesting, and it is also hard to reuse individual parts of it. Let's extract a few components from it. | ||
|
||
First, we will extract `Avatar`: | ||
Denna komponent kan vara svår att ändra på grund av all nestling, det är också svårt att återanvända enskilda delar av den. Låt oss extrahera några komponenter från det. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mix of den
and det
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing. 👍
content/docs/components-and-props.md
Outdated
@@ -173,9 +180,11 @@ function Avatar(props) { | |||
|
|||
The `Avatar` doesn't need to know that it is being rendered inside a `Comment`. This is why we have given its prop a more generic name: `user` rather than `author`. | |||
|
|||
We recommend naming props from the component's own point of view rather than the context in which it is being used. | |||
`Avatar` behöver inte veta att den renderas i en `Comment`-komponent. Därför har vi gett dess Props ett mer generiskt namn: `user` istaället för `author`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
istaället
-> istället
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing. 👍
content/docs/components-and-props.md
Outdated
We recommend naming props from the component's own point of view rather than the context in which it is being used. | ||
`Avatar` behöver inte veta att den renderas i en `Comment`-komponent. Därför har vi gett dess Props ett mer generiskt namn: `user` istaället för `author`. | ||
|
||
Vi rekommenderar att namnge Props från komponentens egen perspektiv snarare än i det sammanhang där den används. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowercase the Props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing. 👍
content/docs/components-and-props.md
Outdated
|
||
Whether you declare a component [as a function or a class](#function-and-class-components), it must never modify its own props. Consider this `sum` function: | ||
Oavsett om du deklarerar en komponent [som en funktion eller en klass](#function-and-class-components), får den aldrig ändra sina egna Props. Ta denna `sum` funktion: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lowercase the Props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing. 👍
content/docs/components-and-props.md
Outdated
|
||
```js | ||
function sum(a, b) { | ||
return a + b; | ||
} | ||
``` | ||
|
||
Such functions are called ["pure"](https://en.wikipedia.org/wiki/Pure_function) because they do not attempt to change their inputs, and always return the same result for the same inputs. | ||
Sådana funktioner kallas ["ren"](https://en.wikipedia.org/wiki/Pure_function) eftersom de inte ändrar sina inputs och alltid returnerar samma resultat för samma inputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plural and singular mix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say Sådana funktioner kallas för ["rena"]
as a more proper translation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing. 👍
First draft of the Components and Props page.