How to use the react-native.ListView.DataSource function in react-native

To help you get started, we’ve selected a few react-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Thinkmill / react-conf-app / app / scenes / Schedule / index.js View on Github external
.tz(talk.time.start, 'America/Los_Angeles')
        .format('dddd');

      // create new section and initialize empty array for section index
      if (!dataBlob[sID]) {
        sectionIDs.push(sID);
        rowIDs[sectionIndex] = [];
        sectionIndex++;
        dataBlob[sID] = sID;
      }

      rowIDs[rowIDs.length - 1].push(talk.id);
      dataBlob[sID + ':' + talk.id] = talk;
    });

    const ds = new ListView.DataSource({
      getSectionData: (dataBlob, sectionID) => dataBlob[sectionID],
      getRowData: (dataBlob, sectionID, rowID) =>
        dataBlob[sectionID + ':' + rowID],
      rowHasChanged: (r1, r2) => r1 !== r2,
      sectionHeaderHasChanged: (s1, s2) => s1 !== s2,
    });

    this.state = {
      dataSource: ds.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs),
      scrollY: new Animated.Value(0),
      now: new Date(),
      appState: AppState.currentState,
    };

    if (Platform.OS === 'ios') {
      // This isn't relevant on Android.
github jsntjinjin / simplereader / app / components / search.js View on Github external
import TagsGroup from '../weight/tagsGroup'
import request from '../utils/httpUtil'
import Dimen from '../utils/dimensionsUtil'
import api from '../common/api'
import config from '../common/config'
import BookDetail from './bookDetail'
import {
  searchHotWords, 
  refreshHowWord,
  searchAutoComplete,
  searchBooks,
  backToInitState
}from '../actions/searchAction'

var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})

class Search extends Component {

  constructor(props) {
    super(props)
    this.state = {
      searchWords: '',
      searchHistory: []
    }
  }

  componentDidMount() {
    const {dispatch} = this.props
    // 请求热词,和获取历史搜索数据
    let searchW = this.props.searchWord
    InteractionManager.runAfterInteractions(()=>{
github dereksweet / ComedyCompanion / src / containers / panes / Jokes / JokesList.js View on Github external
render() {
    const { jokeListState, jokeActions, routingActions, jokeListActions } = this.props;

    let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    const jokeListDS = ds.cloneWithRows(jokeListState.joke_list.map((joke) => { return joke._name }));

    const addJoke = () => {
      jokeActions.setJoke(new Joke());
      routingActions.openModal();
    };

    const editJoke = (id) => {
      Joke.get(id).then((joke) => {
        jokeActions.setJoke(joke);
        routingActions.openModal();
      });
    };

    const renderRow = (rowData, sectionID, rowID, highlightRow) => {
      let joke = jokeListState.joke_list[rowID];
github wwayne / react-native-nba-app / app / components / game / GamePlayers.js View on Github external
constructor (props) {
    super(props)
    this.state = {
      dataSource: new ListView.DataSource({
        rowHasChanged: (row1, row2) => row1 !== row2
      })
    }
  }
github ok406lhq / RTCoin / src / common / listViewComponent2.js View on Github external
constructor(props) {
        super(props);
        //1.设置数据源
        let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
        //2.设置返回数据
        this.state = {dataSource: ds.cloneWithRows(data)};
    }
github jsntjinjin / simplereader / app / components / home / bookshelves.js View on Github external
ScrollView,
  Image,
  Text,
  Modal
} from 'react-native'

import ReadPlatform from '../readPlatform'
import BookDetail from '../bookDetail'
import config from '../../common/config'
import api from '../../common/api'
import Dimen from '../../utils/dimensionsUtil'
import {dateFormat} from '../../utils/formatUtil'
import Toast from '../../weight/toast'
import CommonText from '../../weight/commonText'

var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})

export default class Bookshelves extends Component {

  constructor(props) {
    super(props)
    this.state = {
      bookshelves: [],
      toShow: false,
      focusBook: null
    }
  }

  componentDidMount() {
    this._getBookshelves()
  }
github keybase / client / react-native / react / login / select-signer.mobile.js View on Github external
componentWillMount () {
    const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})

    const devices = this.props.devices.map(function (d) {
      const desc = `Use the device named ${d.name} to authorize this installation`

      return {
        ...d,
        desc: desc
      }
    })

    if (this.props.hasPGP) {
      devices.push({
        name: 'PGP Key',
        desc: 'Use your PGP key'
      })
    }
github cyclejs / cyclejs / native-screen / src / ListView.ts View on Github external
constructor(props: Props) {
    super();
    const dataSource = new RListView.DataSource({
      rowHasChanged: (r1, r2) => r1 !== r2,
    });
    this.state = {dataSource: dataSource.cloneWithRows(props.items)};
  }