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.

Incorrect view direction with default options on react-native-web

See original GitHub issue

Issue Description

The scolling direction is reversed.

Steps to Reproduce / Code Snippets

<GiftedChat
    messages={[...]}
    loadEarlier
    user={{
        _id: 114514,
    }}
    wrapInSafeArea={false}
    isKeyboardInternallyHandled={false}
    onSend={...}
/>

Expected Results

When mouse wheel scrolls down, the message container scrolls down.

Additional Information

  • Nodejs version:
  • React version: v12.14.0
  • React Native version: “react-native-web”: “0.13.1”,
  • react-native-gifted-chat version: “0.16.3”
  • Platform(s) (iOS, Android, or both?): web
  • TypeScript version:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
TimMuncommented, Jul 9, 2020

I managed to get a workaround working… see these threads: https://github.com/necolas/react-native-web/issues/995 https://codesandbox.io/s/react-native-dsyse?file=/src/App.js

You’d need to access the inner FlatList ref within GiftedChat. Assuming your GiftedChat ref is this.giftedChatRef you can do something like let listViewRef = this.giftedChatRef._messageContainerRef, then apply the invertedWheelEvent code from the codesandbox link. Make sure your refs are not null when the listener is attached

Mine looks something like this:

  componentDidMount = () => {
      let listViewRef = this.giftedChatRef._messageContainerRef
      
      if (listViewRef.current) {
        listViewRef.current.getScrollableNode().addEventListener('wheel', this.invertedWheelEvent)
        listViewRef.current.setNativeProps({
          style: {
            transform: "translate3d(0,0,0) scaleY(-1)"
          }
        })
      }
  }

  componentWillUnmount = () => {
    let listViewRef = this.giftedChatRef._messageContainerRef
    if (listViewRef.current) {
      listViewRef.current.getScrollableNode().removeEventListener('wheel', this.invertedWheelEvent)
    }
  }

  invertedWheelEvent = (e) => {
    let listViewRef = this.giftedChatRef._messageContainerRef
    if (listViewRef.current) {
      listViewRef.current.getScrollableNode().scrollTop -= e.deltaY;
      e.preventDefault()
    }
  }
1reaction
hanayashikicommented, Jan 17, 2021

seems this problem is chrome-only

Read more comments on GitHub >

github_iconTop Results From Across the Web

Direct Manipulation - React Native
When using React in the browser for example, you sometimes need to directly modify a DOM node, and the same is true for...
Read more >
React-Native-Web Creates Automatic Classes for in-line Style ...
This is a react native web and a NextJS project. I use inline styles in React, and it seems like RN-Web is messing...
Read more >
Troubleshooting | React Navigation
default.Direction')"​. This and some similar errors might occur if you have a bare React Native project and the library react-native- ...
Read more >
Accessibility - React
Web accessibility (also referred to as a11y) is the design and creation of websites ... React fully supports building accessible websites, often by...
Read more >
Camera - Expo Documentation
If you're installing this in a bare React Native app, you should also follow ... View } from 'react-native'; export default function App()...
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