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
I've found that children function support allows to pass sticky state to children components in a very handy way. This approach can be used instead of introducing another wrapper component that will handle state change with `onStateChange` and pass it to children components
Copy file name to clipboardExpand all lines: README.md
+21-3Lines changed: 21 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ import Sticky from 'react-stickynode';
60
60
61
61
### Handling State Change
62
62
63
-
You can be notified when the state of the sticky component changes by passing a callback to the `onStateChange` prop. The callback will receive an object in the format `{status: CURRENT_STATUS}`, with `CURRENT_STATUS` being an integer representing the status:
63
+
You can be notified when the state of the sticky component changes by passing a callback to the `onStateChange` prop. The callback will receive an object in the format `{status: CURRENT_STATUS}`, with `CURRENT_STATUS` being an integer representing the status:
You can provide a function in the `shouldFreeze` prop which will tell the component to temporarily stop updating during prop and state changes, as well as ignore scroll and resize events. This function should return a boolean indicating whether the component should currently be frozen.
88
+
```js
89
+
importStickyfrom'react-stickynode';
90
+
91
+
<Sticky>
92
+
{status=> {
93
+
if (status.status===Sticky.STATUS_FIXED) {
94
+
return'the component is sticky';
95
+
}
96
+
if (status.status===Sticky.STATUS_ORIGINAL) {
97
+
return'the component in the original position';
98
+
}
99
+
return'the component is released'
100
+
}}
101
+
</Sticky>
102
+
```
103
+
104
+
### Freezing
105
+
106
+
You can provide a function in the `shouldFreeze` prop which will tell the component to temporarily stop updating during prop and state changes, as well as ignore scroll and resize events. This function should return a boolean indicating whether the component should currently be frozen.
0 commit comments