Skip to content

Commit ec56f29

Browse files
masivesjerairrest
authored andcommitted
Update reference assignment in readme (#352)
as per react docs (https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs) this.refs is deprecated. Assigning it with function is a recommended approach
1 parent 6a00545 commit ec56f29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ Chart.js instance can be accessed by placing a ref to the element as:
8686

8787
```js
8888

89+
chartReference = {};
90+
8991
componentDidMount() {
90-
console.log(this.refs.chart.chartInstance); // returns a Chart.js instance reference
92+
console.log(this.chartReference); // returns a Chart.js instance reference
9193
}
9294

9395
render() {
9496
return (
95-
<Doughnut ref='chart' data={data} />
97+
<Doughnut ref={(reference) => this.chartReference = reference } data={data} />
9698
)
9799
}
98100
```

0 commit comments

Comments
 (0)