GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing es.legacy.reactjs.org — React v16.8: La primera con Hooks – React Blog February 06, 2019 by Dan Abramov
¡Con React 16.8, los Hooks de React están disponibles en una versión estable! ¿Qué son los Hooks?Los Hooks te permiten utilizar estado y otras caracteristicas de React sin tener que utilizar clases. También puedes crear tus propios Hooks para compartir lógica con estado reutilizable entre componentes. Si nunca antes has escuchado hablar de los Hooks, es posible que estos recursos te resulten interesante:
No es necesario que aprendas Hooks en estos momentos. Los Hooks no tienen cambios con ruptura y no tenemos planes de eliminar las clases de React. Las preguntas frecuentes sobre Hooks describen la estrategia de adopción gradual. Sin Grandes ReescriturasNosotros no recomendamos reescribir tus aplicaciones existentes para utilizar Hooks de la noche a la mañana. En su lugar, intente utilizar Hooks en alguno de los nuevos componentes y haganos saber que piensa. El código que utiliza Hooks funcionará junto con el código existente que utiliza clases. ¿Puedo utilizar Hooks al día de hoy?¡Sí! A partir de la 16.8.0, React incluye una implementación estable de React Hooks para:
Tenga en cuenta que al habilitar Hooks, todos los paquetes de React necesitan tener una versión igual a 16.8.0 o superior. Los Hooks no funcionarán si olvidas actualizar, por ejemplo, React DOM. React Native soportará Hooks en la versión 0.59. Tooling SupportReact Hooks are now supported by React DevTools. They are also supported in the latest Flow and TypeScript definitions for React. We strongly recommend enabling a new lint rule called What’s NextWe described our plan for the next months in the recently published React Roadmap. Note that React Hooks don’t cover all use cases for classes yet but they’re very close. Currently, only Even while Hooks were in alpha, the React community created many interesting examples and recipes using Hooks for animations, forms, subscriptions, integrating with other libraries, and so on. We’re excited about Hooks because they make code reuse easier, helping you write your components in a simpler way and make great user experiences. We can’t wait to see what you’ll create next! Testing HooksWe have added a new API called For example, the counter example from this page can be tested like this: The calls to If you need to test a custom Hook, you can do so by creating a component in your test, and using your Hook from it. Then you can test the component you wrote. To reduce the boilerplate, we recommend using ThanksWe’d like to thank everybody who commented on the Hooks RFC for sharing their feedback. We’ve read all of your comments and made some adjustments to the final API based on them. InstallationReactReact v16.8.0 is available on the npm registry. To install React 16 with Yarn, run: To install React 16 with npm, run: We also provide UMD builds of React via a CDN: Refer to the documentation for detailed installation instructions. ESLint Plugin for React Hooks
Assuming you already have ESLint installed, run: Then add it to your ESLint configuration: ChangelogReact
React DOM
React Test Renderer
ESLint Plugin: React Hooks
Hooks Changelog Since Alpha VersionsThe above changelog contains all notable changes since our last stable release (16.7.0). As with all our minor releases, none of the changes break backwards compatibility. If you’re currently using Hooks from an alpha build of React, note that this release does contain some small breaking changes to Hooks. We don’t recommend depending on alphas in production code. We publish them so we can make changes in response to community feedback before the API is stable. Here are all breaking changes to Hooks that have been made since the first alpha release:
¿Es útil esta página?Edita esta página |
| You are visitor 01402605 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |