Git Product home page Git Product logo

Comments (11)

2534290808 avatar 2534290808 commented on June 12, 2024

请附上代码,谢谢

from react-native-mjrefresh.

NikiLee2016 avatar NikiLee2016 commented on June 12, 2024

image
主要就是这个情况, 我FlatList部分使用的react-native-ultimate-listview, 这是截取的它的部分源码. 自定义它的下拉刷新组件, 只能通过自定义refreshControl来实现, 大佬那边有办法吗? 让其能够支持refreshControl

from react-native-mjrefresh.

2534290808 avatar 2534290808 commented on June 12, 2024

/**

  • Render a custom scroll component, e.g. with a differently styled RefreshControl.
    */
    renderScrollComponent?: (props: Object) => React.Element,
const ret = React.cloneElement(
  (this.props.renderScrollComponent || this._defaultRenderScrollComponent)(
    scrollProps,
  ),
  {
    ref: this._captureScrollRef,
  },
  cells,
);

如果renderScrollComponent不为空,则刷新效果应在renderScrollComponent里实现,否则还是按照RN官方实现,即refreshControl智能为RefreshControl组件

from react-native-mjrefresh.

2534290808 avatar 2534290808 commented on June 12, 2024

我的例子:

<FlatList
                    keyExtractor={(item)=>item}
                    data={this.state.data}
                    renderItem={({item,index}) => <Text key={index} onPress={()=>alert(111)} style={{height:100}}>{item}</Text>}
                    renderScrollComponent={props=><ScrollView
                        style={{flex:1}}
                        refreshControl={
                            <HuaWeiRefreshControl
                                ref={ref=>this._hw = ref}
                                onRefresh={this._onRefresh}
                            />
                        }
                        {...props}
                    />}
                />

此时的refreshControl既可以是官方RefreshControl,也可以是其他组件(须由MJRefresh包裹)

from react-native-mjrefresh.

NikiLee2016 avatar NikiLee2016 commented on June 12, 2024

好的. 你的意思就是只能使用renderScrollComponent, 对吗? 如果是那样的话, 我只能fork一下react-native-ultimate-listview这个库了, 🤣

from react-native-mjrefresh.

2534290808 avatar 2534290808 commented on June 12, 2024

是的,你可以看一下VirtualizedList组件的源码,官方FlatList是基于VirtualizedList实现的

from react-native-mjrefresh.

NikiLee2016 avatar NikiLee2016 commented on June 12, 2024

好的. 谢谢.
顺便问一下, 你封装的ScrollView组件, 相对于原生ScrollView组件, 优化了那些方面呢?

from react-native-mjrefresh.

2534290808 avatar 2534290808 commented on June 12, 2024

和RN官方一样,只是拓展了可以自定义下拉刷新,:smile:

from react-native-mjrefresh.

NikiLee2016 avatar NikiLee2016 commented on June 12, 2024

👌
我使用了你桥接的SmartRefreshLayout, 效果很好. 现在准备把IOS那边也集成一下你的MjRefresh.
问题弄清楚了, 这个issue应该可以close了.
非常感谢!

from react-native-mjrefresh.

NikiLee2016 avatar NikiLee2016 commented on June 12, 2024

可否加一下你的qq/微信?

from react-native-mjrefresh.

2534290808 avatar 2534290808 commented on June 12, 2024

from react-native-mjrefresh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.