-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translated React without JSX #120
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -4,14 +4,14 @@ title: React Without JSX | |||||||
permalink: docs/react-without-jsx.html | ||||||||
--- | ||||||||
|
||||||||
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. | ||||||||
JSX no es un requisito para usar React. Usar react sin JSX es especialmente conveniente cuando no necesitas configurar herramientas de compilacion en tu ambiente de desarrollo. | ||||||||
|
||||||||
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. | ||||||||
Cada elemento JSX es solamente azucar sintactico para llamar `React.createElement(component, props, ...children)`. Por lo tanto, cualquier cosa que se pueda hacer con JSX se puede hacer con Javascript puro. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
For example, this code written with JSX: | ||||||||
Por ejemplo, este código escrito con JSX: | ||||||||
|
||||||||
```js | ||||||||
class Hello extends React.Component { | ||||||||
class Hello extends React.Component | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yo should not change code samples
Suggested change
|
||||||||
render() { | ||||||||
return <div>Hello {this.props.toWhat}</div>; | ||||||||
} | ||||||||
|
@@ -22,8 +22,7 @@ ReactDOM.render( | |||||||
document.getElementById('root') | ||||||||
); | ||||||||
``` | ||||||||
|
||||||||
can be compiled to this code that does not use JSX: | ||||||||
se puede compilar a este que no usa JSX: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't change the spacing in the line numbers in the original article. It makes our lives easier for reviewing.
Suggested change
|
||||||||
|
||||||||
```js | ||||||||
class Hello extends React.Component { | ||||||||
|
@@ -38,11 +37,11 @@ ReactDOM.render( | |||||||
); | ||||||||
``` | ||||||||
|
||||||||
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). | ||||||||
Si tienes curiosidad por ver mas ejemplos de como JSX se convierte a Javascript, puedes probar el [compilador en linea de Babel](babel://jsx-simple-example). | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
The component can either be provided as a string, or as a subclass of `React.Component`, or a plain function for stateless components. | ||||||||
El componente puede ser proporcionada como una cadena, o como una subclase de `React.Component`, o una función simple para componentes sin estado. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
If you get tired of typing `React.createElement` so much, one common pattern is to assign a shorthand: | ||||||||
Si te cansas de escribir tanto `React.createElement`, un patrón común es assignarlo a una variable corta: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
```js | ||||||||
const e = React.createElement; | ||||||||
|
@@ -53,7 +52,6 @@ ReactDOM.render( | |||||||
); | ||||||||
``` | ||||||||
|
||||||||
If you use this shorthand form for `React.createElement`, it can be almost as convenient to use React without JSX. | ||||||||
|
||||||||
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. | ||||||||
Si usas esta forma abreviada para `React.createElement`, puede ser casi tan conveniente usar React sin JSX. | ||||||||
|
||||||||
Alternativamente, puedes referefirte a proyectos comunitarios como [`react-hyperscript`](https://github.com/mlmorg/react-hyperscript) y [`hyperscript-helpers`](https://github.com/ohanhi/hyperscript-helpers) que ofrecen una sintaxis terser. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
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.