Skip to content

Translate Context #78

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

Merged
merged 28 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
644e580
Translate intro
ricardoerl Feb 5, 2019
7428bd0
Update table of content
ricardoerl Feb 12, 2019
3ae4d84
Translate: When to Use Context
ricardoerl Feb 12, 2019
8c50969
Add heading IDs
ricardoerl Feb 12, 2019
a310ef0
Merge branch 'master' into translate/context
ricardoerl Feb 12, 2019
f40d572
Translate: Before You Use Context
ricardoerl Feb 12, 2019
353669a
Merge branch 'translate/context' of github.com:ricardoerl/es.reactjs.…
ricardoerl Feb 12, 2019
e2b75be
Update translation
ricardoerl Feb 20, 2019
fe7f88e
Update examples
ricardoerl Feb 20, 2019
2147ef0
Update content/docs/context.md
Darking360 Feb 21, 2019
a16f502
Update examples/context/motivation-problem.js
Darking360 Feb 21, 2019
e503368
Update examples/context/motivation-solution.js
Darking360 Feb 21, 2019
9154138
Update content/docs/context.md
Darking360 Feb 21, 2019
3e9f4ae
Update content/docs/context.md
Darking360 Feb 21, 2019
a2335d4
Update content/docs/context.md
Darking360 Feb 21, 2019
b432a87
Update examples/context/reference-caveats-problem.js
Darking360 Feb 21, 2019
05783aa
Update examples/context/reference-caveats-solution.js
Darking360 Feb 21, 2019
38f914d
Update content/docs/context.md
Darking360 Feb 21, 2019
0ec110c
Update content/docs/context.md
Darking360 Feb 21, 2019
5bc3ab2
Fix comments format issue
ricardoerl Feb 21, 2019
8103089
Update content/docs/context.md
Darking360 Feb 21, 2019
99b591e
Update content/docs/context.md
Darking360 Feb 21, 2019
e6e95af
Update content/docs/context.md
Darking360 Feb 21, 2019
89c617c
Update content/docs/context.md
Darking360 Feb 21, 2019
a912a8b
Update content/docs/context.md
Darking360 Feb 21, 2019
eaff519
Update content/docs/context.md
Darking360 Feb 21, 2019
2e8c090
Update content/docs/context.md
Darking360 Feb 21, 2019
a93f0ab
Update examples/context/theme-detailed-app.js
Darking360 Feb 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 67 additions & 66 deletions content/docs/context.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions examples/context/motivation-problem.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class App extends React.Component {

function Toolbar(props) {
// highlight-range{1-4,7}
// The Toolbar component must take an extra "theme" prop
// and pass it to the ThemedButton. This can become painful
// if every single button in the app needs to know the theme
// because it would have to be passed through all components.
// El componente Toolbar debe tener un prop adicional "theme"
// y pasarlo a ThemedButton. Esto puede llegar a ser trabajoso
// si cada botón en la aplicación necesita saber el tema,
// porque tendría que pasar a través de todos los componentes.
return (
<div>
<ThemedButton theme={props.theme} />
Expand Down
22 changes: 11 additions & 11 deletions examples/context/motivation-solution.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// highlight-range{1-4}
// Context lets us pass a value deep into the component tree
// without explicitly threading it through every component.
// Create a context for the current theme (with "light" as the default).
// Context nos permite pasar un valor a lo profundo del árbol de componentes
// sin pasarlo explícitamente a través de cada componente.
// Crear un Context para el tema actual (con "light" como valor predeterminado).
const ThemeContext = React.createContext('light');

class App extends React.Component {
render() {
// highlight-range{1-3,5}
// Use a Provider to pass the current theme to the tree below.
// Any component can read it, no matter how deep it is.
// In this example, we're passing "dark" as the current value.
// Usa un Provider para pasar el tema actual al árbol de abajo.
// Cualquier componente puede leerlo, sin importar qué tan profundo se encuentre.
// En este ejemplo, estamos pasando "dark" como valor actual.
return (
<ThemeContext.Provider value="dark">
<Toolbar />
Expand All @@ -19,8 +19,8 @@ class App extends React.Component {
}

// highlight-range{1,2}
// A component in the middle doesn't have to
// pass the theme down explicitly anymore.
// Un componente en el medio no tiene que
// pasar el tema hacia abajo explícitamente.
function Toolbar(props) {
return (
<div>
Expand All @@ -31,9 +31,9 @@ function Toolbar(props) {

class ThemedButton extends React.Component {
// highlight-range{1-3,6}
// Assign a contextType to read the current theme context.
// React will find the closest theme Provider above and use its value.
// In this example, the current theme is "dark".
// Asigna un contextType para leer el contexto del tema actual.
// React encontrará el Provider superior más cercano y usará su valor.
// En este ejemplo, el tema actual es "dark".
static contextType = ThemeContext;
render() {
return <Button theme={this.context} />;
Expand Down
6 changes: 3 additions & 3 deletions examples/context/multiple-contexts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Theme context, default to light theme
const ThemeContext = React.createContext('light');

// Signed-in user context
// Contexto de usuario registrado
const UserContext = React.createContext({
name: 'Guest',
});
Expand All @@ -10,7 +10,7 @@ class App extends React.Component {
render() {
const {signedInUser, theme} = this.props;

// App component that provides initial context values
// Componente App que proporciona valores de contexto iniciales
// highlight-range{2-3,5-6}
return (
<ThemeContext.Provider value={theme}>
Expand All @@ -31,7 +31,7 @@ function Layout() {
);
}

// A component may consume multiple contexts
// Un componente puede consumir múltiples contextos.
function Content() {
// highlight-range{2-10}
return (
Expand Down
8 changes: 4 additions & 4 deletions examples/context/theme-detailed-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ThemeContext, themes} from './theme-context';
import ThemedButton from './themed-button';

// An intermediate component that uses the ThemedButton
// Un componente intermedio que utiliza ThemedButton.
function Toolbar(props) {
return (
<ThemedButton onClick={props.changeTheme}>
Expand Down Expand Up @@ -29,9 +29,9 @@ class App extends React.Component {

render() {
//highlight-range{1-3}
// The ThemedButton button inside the ThemeProvider
// uses the theme from state while the one outside uses
// the default dark theme
// El botón ThemedButton dentro de ThemeProvider
// usa el tema del estado mientras que el exterior usa
// el tema oscuro predeterminado
//highlight-range{3-5,7}
return (
<Page>
Expand Down
2 changes: 1 addition & 1 deletion examples/context/theme-detailed-theme-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export const themes = {

// highlight-range{1-3}
export const ThemeContext = React.createContext(
themes.dark // default value
themes.dark // valor por defecto
);