Skip to content

Commit 2f28d5d

Browse files
authored
Translation of the “React without JSX” page
translated react-without-jsx
2 parents ec4abbf + 8203a23 commit 2f28d5d

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

content/docs/nav.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
- id: react-without-es6
6363
title: React Without ES6
6464
- id: react-without-jsx
65-
title: React Without JSX
65+
title: React sans JSX
6666
- id: reconciliation
6767
title: Reconciliation
6868
- id: refs-and-the-dom

content/docs/react-without-jsx.md

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,57 @@
11
---
22
id: react-without-jsx
3-
title: React Without JSX
3+
title: React sans JSX
44
permalink: docs/react-without-jsx.html
55
---
66

7-
JSX is not a requirement for using React. Using React without JSX is especially convenient when you don't want to set up compilation in your build environment.
7+
Vous n'êtes pas obligé·e d'employer JSX pour utiliser React. React sans JSX vous dispense de configurer votre environnement de travail pour gérer la compilation de votre code.
88

9-
Each JSX element is just syntactic sugar for calling `React.createElement(component, props, ...children)`. So, anything you can do with JSX can also be done with just plain JavaScript.
9+
Chaque élément JSX n'est rien de plus que du sucre syntaxique pour `React.createElement(component, props, ...children)`. Par conséquent, tout ce que vous pouvez faire avec JSX peut aussi être réalisé en Javascript brut.
1010

11-
For example, this code written with JSX:
11+
Prenons par exemple ce code écrit avec JSX :
1212

1313
```js
1414
class Hello extends React.Component {
1515
render() {
16-
return <div>Hello {this.props.toWhat}</div>;
16+
return <div>Bonjour {this.props.toWhat}</div>;
1717
}
1818
}
1919

2020
ReactDOM.render(
21-
<Hello toWhat="World" />,
21+
<Hello toWhat="monde" />,
2222
document.getElementById('root')
2323
);
2424
```
2525

26-
can be compiled to this code that does not use JSX:
26+
Il peut être compilé vers ce code qui n'utilise pas JSX :
2727

2828
```js
2929
class Hello extends React.Component {
3030
render() {
31-
return React.createElement('div', null, `Hello ${this.props.toWhat}`);
31+
return React.createElement('div', null, `Bonjour ${this.props.toWhat}`);
3232
}
3333
}
3434

3535
ReactDOM.render(
36-
React.createElement(Hello, {toWhat: 'World'}, null),
36+
React.createElement(Hello, {toWhat: 'monde'}, null),
3737
document.getElementById('root')
3838
);
3939
```
4040

41-
If you're curious to see more examples of how JSX is converted to JavaScript, you can try out [the online Babel compiler](babel://jsx-simple-example).
41+
Si vous voulez voir plus d'exemples de conversion de code JSX en JavaScript brut, vous pouvez essayer [le compilateur Babel en ligne](babel://jsx-simple-example).
4242

43-
The component can either be provided as a string, or as a subclass of `React.Component`, or a plain function for stateless components.
43+
Le composant peut être soit une chaîne de caractères, soit une sous-classe de `React.Component`, soit une fonction simple pour les composants sans état.
4444

45-
If you get tired of typing `React.createElement` so much, one common pattern is to assign a shorthand:
45+
Si vous n'avez pas envie de taper `React.createElement` à chaque fois, vous pouvez à la place créer un raccourci :
4646

4747
```js
4848
const e = React.createElement;
4949

5050
ReactDOM.render(
51-
e('div', null, 'Hello World'),
51+
e('div', null, 'Bonjour, monde'),
5252
document.getElementById('root')
5353
);
5454
```
55+
Si vous utilisez un tel raccourci pour `React.createElement`, utiliser React sans JSX devient presque aussi pratique.
5556

56-
If you use this shorthand form for `React.createElement`, it can be almost as convenient to use React without JSX.
57-
58-
Alternatively, you can refer to community projects such as [`react-hyperscript`](https://github.com/mlmorg/react-hyperscript) and [`hyperscript-helpers`](https://github.com/ohanhi/hyperscript-helpers) which offer a terser syntax.
59-
57+
Dans le même esprit, vous pouvez aller regarder des projets tels que [`react-hyperscript`](https://github.com/mlmorg/react-hyperscript) ou [`hyperscript-helpers`](https://github.com/ohanhi/hyperscript-helpers), qui proposent une syntaxe encore plus concise.

0 commit comments

Comments
 (0)