Commit b3e2959
authored
fix: optimize InView (#392)
This changes the rendering flow in the <InView> component, optimizing it for the children.
Previously it had a an internal state used to store the current inView and entry values. But it was only really used by the component when using the render props pattern. This lead to unnecessary renders for the plain component.
Another optimization tried to limit the state updates, so it would only occur if inView changed. This however meant you wouldn't get the correct entry value in the render prop, since it would only update when inView changes. This would prevent you from getting the latest threshold or isVisible values.1 parent a9eac7e commit b3e2959
1 file changed
+13
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | 47 | | |
55 | 48 | | |
56 | 49 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 50 | + | |
| 51 | + | |
61 | 52 | | |
62 | 53 | | |
63 | 54 | | |
| |||
87 | 78 | | |
88 | 79 | | |
89 | 80 | | |
| 81 | + | |
90 | 82 | | |
| 83 | + | |
91 | 84 | | |
| 85 | + | |
92 | 86 | | |
93 | 87 | | |
94 | 88 | | |
| |||
97 | 91 | | |
98 | 92 | | |
99 | 93 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
| |||
109 | 107 | | |
110 | 108 | | |
111 | 109 | | |
112 | | - | |
113 | 110 | | |
| 111 | + | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
| |||
0 commit comments