You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/community/tools-starter-kits.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -36,3 +36,4 @@ Ready to grow boilerplate with react-router, redux, saga, webpack 3, jest w/ cov
36
36
***[EDGE Platform](https://github.com/sebastian-software/edge)** Universal React/SSR + Apollo GraphQL + JS/CSS Code Splitting + Fine-Tuned Webpack + Localization/Internationalization. Most things are external dependencies. Boilerplate available.
37
37
***[bae](https://github.com/siddharthkp/bae)** Zero config toolkit. SSR (with data fetching) + routing + streaming + styling (with styled-components) + HMR out of the box.
38
38
***[breko-hub](https://github.com/tomatau/breko-hub)** A production ready boilerplate for universal react applications. Complete with code splitting, server render (using koa), redux, sagas, debugging, hot-reloading (live updates on the server), css-modules, scss, super fast integration tests and unit tests. There's also a big focus on clean code and smaller files.
39
+
***[appseed](https://github.com/rosoftdeveloper/appseed)** A production ready boilerplate for UI-Ready react applications. The frontend can be bundled with various backends: Flask, Laravel, Express.
Sử dụng nó, chúng ta đầu tiên tạo một ref đến một element
202
203
trong JSX của một component class:
204
+
=======
205
+
Only ever use CSS that removes this outline, for example by setting `outline: 0`, if you are replacing it with another focus outline implementation.
206
+
207
+
### Mechanisms to skip to desired content {#mechanisms-to-skip-to-desired-content}
208
+
209
+
Provide a mechanism to allow users to skip past navigation sections in your application as this assists and speeds up keyboard navigation.
210
+
211
+
Skiplinks or Skip Navigation Links are hidden navigation links that only become visible when keyboard users interact with the page. They are very easy to implement with internal page anchors and some styling:
Also use landmark elements and roles, such as `<main>` and `<aside>`, to demarcate page regions as assistive technology allow the user to quickly navigate to these sections.
216
+
217
+
Read more about the use of these elements to enhance accessibility here:
Our React applications continuously modify the HTML DOM during runtime, sometimes leading to keyboard focus being lost or set to an unexpected element. In order to repair this, we need to programmatically nudge the keyboard focus in the right direction. For example, by resetting keyboard focus to a button that opened a modal window after that modal window is closed.
224
+
225
+
MDN Web Docs takes a look at this and describes how we can build [keyboard-navigable JavaScript widgets](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets).
226
+
227
+
To set focus in React, we can use [Refs to DOM elements](/docs/refs-and-the-dom.html).
228
+
229
+
Using this, we first create a ref to an element in the JSX of a component class:
230
+
231
+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
203
232
```javascript{4-5,8-9,13}
204
233
class CustomTextInput extends React.Component {
205
234
constructor(props) {
@@ -230,11 +259,15 @@ input một cách rõ ràng bằng cách sử dụng DOM API nguyên bản
230
259
this.textInput.current.focus();
231
260
}
232
261
262
+
<<<<<<<HEAD
233
263
```
234
264
Đôi khi một component cha cần được set focus vào một element
235
265
trong component con. Chúng ta có thể thực hiện bằng cách [phơi bày DOM refs tới
Sometimes a parent component needs to set focus to an element in a child component. We can do this by [exposing DOM refs to parent components](/docs/refs-and-the-dom.html#exposing-dom-refs-to-parent-components) through a special prop on the child component that forwards the parent's ref to the child's DOM node.
270
+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
238
271
239
272
thông qua một prop đặc biệt ở component con để chuyển tiếp
240
273
ref của component cha đến DOM node của component con.
@@ -260,6 +293,30 @@ class Parent extends React.Component {
260
293
261
294
// Bây giờ bạn có thể set focus khi cần thiết.
262
295
this.inputElement.current.focus();
296
+
<<<<<<< HEAD
297
+
=======
298
+
```
299
+
300
+
When using a HOC to extend components, it is recommended to [forward the ref](/docs/forwarding-refs.html) to the wrapped component using the `forwardRef` function of React. If a third party HOC does not implement ref forwarding, the above pattern can still be used as a fallback.
301
+
302
+
A great focus management example is the [react-aria-modal](https://github.com/davidtheclark/react-aria-modal). This is a relatively rare example of a fully accessible modal window. Not only does it set initial focus on
303
+
the cancel button (preventing the keyboard user from accidentally activating the success action) and trap keyboard focus inside the modal, it also resets focus back to the element that initially triggered the modal.
304
+
305
+
>Note:
306
+
>
307
+
>While this is a very important accessibility feature, it is also a technique that should be used judiciously. Use it to repair the keyboard focus flow when it is disturbed, not to try and anticipate how
308
+
>users want to use applications.
309
+
310
+
## Mouse and pointer events {#mouse-and-pointer-events}
311
+
312
+
Ensure that all functionality exposed through a mouse or pointer event can also be accessed using the keyboard alone. Depending only on the pointer device will lead to many cases where keyboard users cannot use your application.
313
+
314
+
To illustrate this, let's look at a prolific example of broken accessibility caused by click events. This is the outside click pattern, where a user can disable an opened popover by clicking outside the element.
315
+
316
+
<imgsrc="../images/docs/outerclick-with-mouse.gif"alt="A toggle button opening a popover list implemented with the click outside pattern and operated with a mouse showing that the close action works." />
317
+
318
+
This is typically implemented by attaching a `click` event to the `window` object that closes the popover:
319
+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
263
320
264
321
```
265
322
Khi sử dụng HOC để mở rộng components, [chuyển tiếp
@@ -338,6 +395,7 @@ constructor(props) {
338
395
}
339
396
}
340
397
```
398
+
<<<<<<< HEAD
341
399
Điều này có thể hoạt động tốt cho người dùng với những thiết
342
400
bị pointer, như chuột, nhưng thao tác nó với chỉ bàn phím sẽ khiến chức năng bị
343
401
hư hỏng khi tab sang element tiếp theo
@@ -351,6 +409,15 @@ obscuring other screen elements." />
351
409
352
410
Chúng ta cũng có thể đạt được chức năng tương tự bằng cách sử
353
411
dụng những event handlers thích hợp, như `onBlur` và `onFocus`:
412
+
=======
413
+
414
+
This may work fine for users with pointer devices, such as a mouse, but operating this with the keyboard alone leads to broken functionality when tabbing to the next element as the `window` object never receives a `click` event. This can lead to obscured functionality which blocks users from using your application.
415
+
416
+
<imgsrc="../images/docs/outerclick-with-keyboard.gif"alt="A toggle button opening a popover list implemented with the click outside pattern and operated with the keyboard showing the popover not being closed on blur and it obscuring other screen elements." />
417
+
418
+
The same functionality can be achieved by using an appropriate event handlers instead, such as `onBlur` and `onFocus`:
419
+
420
+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
354
421
```javascript{19-29,31-34,37-38,40-41}
355
422
class BlurExample extends React.Component {
356
423
constructor(props) {
@@ -404,6 +471,7 @@ class BlurExample extends React.Component {
404
471
}
405
472
}
406
473
```
474
+
<<<<<<< HEAD
407
475
Đoạn code cho thấy chức năng của cả con trỏ
408
476
và bàn phím của người dùng. Cũng lưu ý rằng thêm thuộc tính `aria-*` vào để hỗ trợ
409
477
người dùng. Đơn giãn hơn là để sự kiện bàn phím cho phép `arrow key` tương tác với
@@ -415,12 +483,24 @@ tùy chọn popover chưa được implement.
415
483
phụ thuộc vào con trỏ và sự kiện từ chuột sẽ làm hỏng chức năng cho người dùng bàn phím. Luôn luôn
416
484
test với bàn phím sẽ ngay lập tức phát hiện được những khu vực có vấn đề, sau đó
417
485
có thể sửa bằng cách dùng những handler để nhận input từ bàn phím.
486
+
=======
487
+
488
+
This code exposes the functionality to both pointer device and keyboard users. Also note the added `aria-*` props to support screen-reader users. For simplicity's sake the keyboard events to enable `arrow key` interaction of the popover options have not been implemented.
489
+
490
+
<imgsrc="../images/docs/blur-popover-close.gif"alt="A popover list correctly closing for both mouse and keyboard users." />
491
+
492
+
This is one example of many cases where depending on only pointer and mouse events will break functionality for keyboard users. Always testing with the keyboard will immediately highlight the problem areas which can then be fixed by using keyboard aware event handlers.
493
+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
418
494
419
495
## Những Widgets phức tạp hơn {#more-complex-widgets}
420
496
497
+
<<<<<<< HEAD
421
498
Trải nghiệm người dùng phức tạp không nên khiến mức độ accessibilty bị giảm đi.
422
499
Trong khi đó accessibility dễ đạt được nhất bằng cách code sát với HTML nhất có thể,
423
500
Ngay cả với widget phức tạp nhất.
501
+
=======
502
+
A more complex user experience should not mean a less accessible one. Whereas accessibility is most easily achieved by coding as close to HTML as possible, even the most complex widget can be coded accessibly.
503
+
>>>>>>> 23b242edc4c7eeee5798953ba205e36cc71016b8
424
504
425
505
Ở đây chúng ta cần kiến thức từ [ARIA Roles](https://www.w3.org/TR/wai-aria/#roles) cũng như [ARIA States and Properties](https://www.w3.org/TR/wai-aria/#states_and_properties). Đây là những công cụ có sẵn những thuộc tính HTML đã được hỗ trợ đầy đủ trong JSX và cho phép chúng ta xây dựng một trang web accessibility đầy đủ, những React component có chức năng cao cấp.
426
506
@@ -482,6 +562,7 @@ Cho đến thời điểm hiện tại, cách dễ nhất và cũng là một tr
482
562
là kiểm tra toàn bộ trang web của bạn có thể tương tác và sử dụng được
483
563
chỉ bằng bàn phím hay không. Chúng ta thực hiện điều này bằng cách:
484
564
565
+
<<<<<<< HEAD
485
566
1. Tháo chuột của bạn ra khỏi máy tính.
486
567
2. Sử dụng `Tab` và `Shift+Tab` để duyệt web.
487
568
3. Sử dụng `Enter` để tương tác với những phần tử trong trang web.
@@ -492,13 +573,31 @@ chỉ bằng bàn phím hay không. Chúng ta thực hiện điều này bằng
492
573
Chúng ta có thể kiểm tra một số chức năng accessibility trực tiếp trong code JSX.
493
574
Thường thì bộ kiểm tra intellisense sẽ được cung cấp sẵn trong IDE cho những vai trò
494
575
ARIA, states và properties. Chúng ta cũng có thể truy cập bằng những công cụ dưới đây:
576
+
=======
577
+
1. Disconnecting your mouse.
578
+
1. Using `Tab` and `Shift+Tab` to browse.
579
+
1. Using `Enter` to activate elements.
580
+
1. Where required, using your keyboard arrow keys to interact with some elements, such as menus and dropdowns.
581
+
582
+
### Development assistance {#development-assistance}
583
+
584
+
We can check some accessibility features directly in our JSX code. Often intellisense checks are already provided in JSX aware IDE's for the ARIA roles, states and properties. We also have access to the following tool:
plugin cho ESLint cung cấp AST phản hồi AST về những vấn đề liên quan đến accessibility trong JSX của bạn. Nhiều IDE's cho phép bạn tích hợp trực tiếp vào code analysis và source code windows.
498
590
591
+
<<<<<<< HEAD
499
592
[Create React App](https://github.com/facebookincubator/create-react-app) có plugin này
500
593
với một tập hợp về những quy tắc kích hoạt. Nếu bạn muốn cho phép quy tắc accessibility hơn nữa,
501
594
bạn có thể tạo một `.eslintrc` file trong root của project bằng nội dung sau đây:
595
+
=======
596
+
The [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) plugin for ESLint provides AST linting feedback regarding accessibility issues in your JSX. Many IDE's allow you to integrate these findings directly into code analysis and source code windows.
597
+
598
+
[Create React App](https://github.com/facebookincubator/create-react-app) has this plugin with a subset of rules activated. If you want to enable even more accessibility rules, you can create an `.eslintrc` file in the root of your project with this content:
Copy file name to clipboardExpand all lines: content/docs/hooks-faq.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -656,7 +656,7 @@ Note that in the above example we **need** to keep the function in the dependenc
656
656
657
657
### What can I do if my effect dependencies change too often? {#what-can-i-do-if-my-effect-dependencies-change-too-often}
658
658
659
-
Sometimes, your effect may be using reading state that changes too often. You might be tempted to omit that state from a list of dependencies, but that usually leads to bugs:
659
+
Sometimes, your effect may be using state that changes too often. You might be tempted to omit that state from a list of dependencies, but that usually leads to bugs:
0 commit comments