Code Monkey home page Code Monkey logo

Comments (4)

erichua23 avatar erichua23 commented on May 25, 2024

Custom your own renderRow and use a flag in the row data item may help.

from react-native-search-list.

Phuzer avatar Phuzer commented on May 25, 2024

@erichua23 can you give a hint how to do that? I'm stuck there as well. I have a "selected" flag that changes when the row is selected, but i noticed that the function renderRow never gets called (re-rendered) when i use forceUpdate() inside selectItem function. The only time the background of the selected row changes, is when i'm searching (keyboard opened). Is this a bug or something is missing?

from react-native-search-list.

QuYunFengg avatar QuYunFengg commented on May 25, 2024

@Phuzer Have you solved this problem? I have the same problem now.

from react-native-search-list.

tong233 avatar tong233 commented on May 25, 2024

It works for me

  pressItem = item => {
    let index = this.state.dataSource.findIndex(element => {
      return element.id === item.id
    })
    if (index === -1) return
    const { dataSource } = this.state
    const data = immutable(dataSource, {
      [index]: { checked: { $set: !item.checked } }
    })
    this.setState({ dataSource: data })
  }

  renderRow = (item, sectionID, rowID, highlightRowFunc, isSearching) => {
    return (
      <TouchableOpacity onPress={() => this.pressItem(item)}>
        <View
          key={rowID}
          style={{
            flex: 1,
            marginLeft: 20,
            height: rowHeight,
            justifyContent: 'center',
            backgroundColor: item.checked ? 'red' : 'white'
          }}
        >
          {/* use `HighlightableText` to highlight the search result */}
          <HighlightableText
            matcher={item.matcher}
            text={item.PerName}
            textColor={'#000'}
            hightlightTextColor={'#0069c0'}
          />
        </View>
      </TouchableOpacity>
    )
  }

from react-native-search-list.

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.