scrollPage.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React from "react";
  2. import { ScrollView, RefreshControl } from "react-native";
  3. function scrollPage(Component) {
  4. class NewPage extends React.Component {
  5. constructor(props) {
  6. super(props);
  7. this.state = {
  8. refreshing: false,
  9. };
  10. }
  11. _onRefresh = () => {
  12. this.setState({ refreshing: true });
  13. fetchData().then(() => {
  14. this.setState({ refreshing: false });
  15. });
  16. };
  17. render(props) {
  18. return (
  19. <ScrollView
  20. contentContainerStyle={{ flexGrow: 1 }}
  21. refreshControl={
  22. <RefreshControl
  23. refreshing={this.state.refreshing}
  24. onRefresh={this._onRefresh}
  25. enabled={true}
  26. />
  27. }
  28. >
  29. <Component {...props} />
  30. </ScrollView>
  31. );
  32. }
  33. }
  34. return () => {
  35. return <NewPage />;
  36. };
  37. }
  38. export default scrollPage;