question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use scrollToBottomComponent?

See original GitHub issue

Issue Description

I’m not sure how to use scrollToBottomComponent to customize the component with scrollToBottom={true}.

Got the following error when trying to use this two props together: ExceptionsManager.js:82 Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.

Steps to Reproduce / Code Snippets

private _scrollToBottomComponent(props) {
  return (
    <View style={styles.scrollToBottomContainer}>
      <TouchableOpacity {...props}>
        <Text>Image here</Text>
     </TouchableOpacity>
   </View>
  );
}

Expected Results

To be able to center the component and change the current <Text>V</Text> to an image or possibly animation with either lottie-react-native or react-native-element.

Additional Information

  • Nodejs version: 11.13.0
  • React version: 16.8.3
  • React Native version: 0.59.3
  • react-native-gifted-chat version: 0.7.2
  • Platform(s) (iOS, Android, or both?): Both

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

7reactions
junminleeKScommented, Apr 19, 2019

I found this snippet pertaining to the bottom scroll component inside the source code:

renderScrollToBottomWrapper() {
  const scrollToBottomComponent = (
    <View style={styles.scrollToBottomStyle}>
      <TouchableOpacity onPress={this.scrollToBottom} hitSlop={{ top: 5, left: 5, right: 5, bottom: 5 }}>
        <Text>V</Text>
      </TouchableOpacity>
    </View>
  );

  if (this.props.scrollToBottomComponent) {
    return (
      <TouchableOpacity onPress={this.scrollToBottom} hitSlop={{ top: 5, left: 5, right: 5, bottom: 5 }}>
        {this.props.scrollToBottomComponent}
      </TouchableOpacity>
    );
  }
  return scrollToBottomComponent;
}

It seems this.props.scrollToBottomComponent should be this.props.scrollToBottomComponent() since the documentation states that you need to pass in a function.

I also noticed that the default component is styled so that it appears on the bottom right of the screen as seen here:

scrollToBottomStyle: {
  opacity: 0.8,
  position: 'absolute',
  paddingHorizontal: 15,
  paddingVertical: 8,
  right: 10,
  bottom: 30,
  zIndex: 999,
  height: 40,
  width: 40,
  borderRadius: 20,
  backgroundColor: Color.white,
  alignItems: 'center',
  justifyContent: 'center',
  shadowColor: Color.black,
  shadowOpacity: 0.5,
  shadowOffset: { width: 0, height: 0 },
  shadowRadius: 1,
}

If we try to do the same absolute positioning by styling our own component that is passed in then it will not achieve the same behavior. Our component is wrapped by TouchableOpacity whereas the default component wraps TouchableOpacity in a view that receives the above style.

1reaction
msqarcommented, Sep 7, 2019

Hey guys, i found there’s no way to customize the container, I don’t want it to be a circle-shaped with opacity. How can I edit the container? in the props it says i can pass the scrollToBottomStyle, but it’s not using it anywhere within the code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chat app with React Native (part 4) - A guide to create Chat UI ...
Use IconButton component from react-native-paper to customize this button. Add the prop scrollToBottomComponent to <GiftedChat /> . Add ...
Read more >
Chat app with React Native (part 4): Create Chat UI Screens ...
Use the IconButton component from react-native-paper to customize this button. Add the prop scrollToBottomComponent to <GiftedChat /> . Add ...
Read more >
How to add max height to my ScrollToBottom component?
I am using ScrollToBottom from the library 'react-scroll-to-bottom'. ... Have you tried to use css property max-height ...
Read more >
Creating a Chat Component With React Native | by Yash Gupta
scrollToBottom}scrollToBottomComponent={this.props. ... Then, we use something called a pairing function from mathematics.
Read more >
react-native-gifted-chat - npm
Start using react-native-gifted-chat in your project by running `npm i ... scrollToBottomComponent (Function) - Custom Scroll To Bottom ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found