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: patterns/third-party/README.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
---
6
6
7
-
React is probably one of the best choices for building UI. Good design, support and community. However, there are cases where we want to use an external service or we want to integrate something completely different. We all know that React works heavily with the actual DOM and basically controls what's rendered on the screen. That's why integrating of third-party components could be tricky. In this article we will see how to mix React and jQuery's UI plugin and do it safely.
7
+
React is probably one of the best choices for building UI. Good design, support and community. However, there are cases where we want to use an external service or we want to integrate something completely different. We all know that React works heavily with the actual DOM and basically controls what's rendered on the screen. That's why integrating of third-party components may be tricky. In this section we will see how to mix React and jQuery's UI plugin and do it safely.
8
8
9
9
## The example
10
10
@@ -62,7 +62,7 @@ class App extends React.Component {
The entry point is our `App` class. It uses the `Tags` component that displays an unordered list based on the passed `tags` prop. When React renders the list on the screen we know that we have a `<ul>` tag so we can hook it to the jQuery plugin.
65
+
The entry point is our `App` class. It uses the `Tags` component that displays an unordered list based on the passed `tags` prop. When React renders the list on the screen we know that we have a `<ul>` tag so we can hook it up to the jQuery plugin.
66
66
67
67
## Force a single-render
68
68
@@ -76,7 +76,7 @@ class Tags extends React.Component {
76
76
...
77
77
```
78
78
79
-
By always returning `false` here we are saying that our component will never rerender. If defined `shouldComponentUpdate` is used by React to understand whether to trigger `render` or not. That's ideal for our case because we want to place the markup on the page using React but we don't want to rely on it after that.
79
+
By always returning `false` here we are saying that our component will never re-render. If defined `shouldComponentUpdate` is used by React to understand whether to trigger `render` or not. That's ideal for our case because we want to place the markup on the page using React but we don't want to rely on it after that.
80
80
81
81
## Initializing the plugin
82
82
@@ -99,7 +99,7 @@ class Tags extends React.Component {
99
99
...
100
100
```
101
101
102
-
The code above together with `shouldComponentUpdate`lead to React rendering the `<ul>` with two items and then *tag-it* transforms it to a working tag editing widget.
102
+
The code above together with `shouldComponentUpdate`leads to React rendering the `<ul>` with two items and then *tag-it* transforms it to a working tag editing widget.
103
103
104
104
## Controlling the plugin using React
105
105
@@ -136,7 +136,7 @@ class App extends React.Component {
136
136
}
137
137
```
138
138
139
-
We use the internal state as a data storage for the value of the newly added field. Every time when we click the button we update the state and trigger rerendering of `Tags` component. However, because of `shouldComponentUpdate` we update nothing. The only one change is that we get a value of the `newTag` prop which may be captured via another lifecycle method - `componentWillReceiveProps`:
139
+
We use the internal state as a data storage for the value of the newly added field. Every time when we click the button we update the state and trigger re-rendering of `Tags` component. However, because of `shouldComponentUpdate` we have no any updates on the screen. The only one change is that we get a new value of the `newTag` prop which may be captured via another lifecycle method - `componentWillReceiveProps`:
140
140
141
141
```jsx
142
142
classTagsextendsReact.Component {
@@ -173,6 +173,6 @@ class Tags extends React.Component {
173
173
};
174
174
```
175
175
176
-
## Conclusion
176
+
## Final thoughts
177
177
178
-
Even though React is manipulating the DOM tree we are able to integrate third-party libraries and services. The available lifecycle methods give us enough control on the rendering process.
178
+
Even though React is manipulating the DOM tree we are able to integrate third-party libraries and services. The available lifecycle methods give us enough control on the rendering process so they are the perfect bridge between React and non-React code.
0 commit comments