@gpbagga/react-native-read-more

1.1.1 • Public • Published

react-native-read-more

import ReactNativeReadMore from '@gpbagga/react-native-read-more'

const App = () => {
  const TextComponent = useCallback(() => (
    <Text
    style={{
      margin: 30,
      fontSize: 16,
      fontFamily: 'sans-serif-condensed'
    }}>
      <Text
      style={{
        fontWeight: 'bold'
      }}
      >{SAMPLESTR.substring(0, 30)}</Text>
      {SAMPLESTR.substring(30, 100)}
      <Text
        style={{ fontSize: 20, fontWeight: 'bold' }} >{SAMPLESTR.substring(100, 110)}</Text>
      <Text style={{ fontSize: 30 }} >{SAMPLESTR.substring(110)}</Text>
    </Text>
  ), [])

  return (
    <ReactNativeReadMore
      TextComponent={TextComponent}
      numLinesForReadMore={3}
      ReadMoreComponent={<Text>...read more</Text>}
      ReadLessComponent={<Text>...read less</Text>}
    />
  )
}

export default App
  • Make sure that style of Parent View of ReactNativeReadMore component does NOT include flexDirection:'row' and flexWrap:'wrap'.
  • Keep TextComponent inside useCallback to not render the ReactNativeReadMore component again on rerender of the App when text inside it remains same.

Readme

Keywords

none

Package Sidebar

Install

npm i @gpbagga/react-native-read-more

Weekly Downloads

2

Version

1.1.1

License

ISC

Unpacked Size

16.3 kB

Total Files

8

Last publish

Collaborators

  • gpbagga