Skip to content

Commit 9ce50e2

Browse files
authored
Merge pull request #2 from chenc041/chenc041-patch-2
chore: format code style in 282
2 parents e838318 + 1732cb6 commit 9ce50e2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5956,8 +5956,8 @@ You can download the PDF and Epub version of this repository from the latest run
59565956
Refs will not get passed through because ref is not a prop. It handled differently by React just like **key**. If you add a ref to a HOC, the ref will refer to the outermost container component, not the wrapped component. In this case, you can use Forward Ref API. For example, we can explicitly forward refs to the inner FancyButton component using the React.forwardRef API.
59575957
59585958
The below HOC logs all props,
5959-
5960-
```javascript
5959+
5960+
```javascript
59615961
function logProps(Component) {
59625962
class LogProps extends React.Component {
59635963
componentDidUpdate(prevProps) {
@@ -5977,11 +5977,11 @@ You can download the PDF and Epub version of this repository from the latest run
59775977
return <LogProps {...props} forwardedRef={ref} />;
59785978
});
59795979
}
5980-
```
5980+
```
59815981
59825982
Let's use this HOC to log all props that get passed to our “fancy button” component,
59835983
5984-
```javascript
5984+
```javascript
59855985
class FancyButton extends React.Component {
59865986
focus() {
59875987
// ...
@@ -5990,11 +5990,11 @@ You can download the PDF and Epub version of this repository from the latest run
59905990
// ...
59915991
}
59925992
export default logProps(FancyButton);
5993-
```
5993+
```
59945994
59955995
Now lets create a ref and pass it to FancyButton component. In this case, you can set focus to button element.
59965996
5997-
```javascript
5997+
```javascript
59985998
import FancyButton from './FancyButton';
59995999

60006000
const ref = React.createRef();
@@ -6004,7 +6004,7 @@ You can download the PDF and Epub version of this repository from the latest run
60046004
handleClick={handleClick}
60056005
ref={ref}
60066006
/>;
6007-
```
6007+
```
60086008
60096009
**[⬆ Back to Top](#table-of-contents)**
60106010

0 commit comments

Comments
 (0)