Skip to content

Instantly share code, notes, and snippets.

View nelsonprsousa's full-sized avatar
:octocat:
Working from home

Nelson Sousa nelsonprsousa

:octocat:
Working from home
View GitHub Profile
@nelsonprsousa
nelsonprsousa / useScrollToTop.ts
Last active January 29, 2022 15:30
The expected native behavior of scrollable components is to respond to events from navigation that will scroll to top when tapping on the active tab as you would expect from native tab bars. Works with react-native-navigation.
import { useEffect, useRef } from 'react';
import { ScrollView } from 'react-native';
import { Navigation } from 'react-native-navigation';
const useScrollToTop = ({
selectedTabIndex,
}: {
selectedTabIndex: number;
}): React.RefObject<ScrollView> => {
const scrollViewRef = useRef<ScrollView>(null);
namespace XUnitTestProject
{
using Xunit;
public static class SwitchStatementMapper
{
// Don't judge me, it's only for educational purposes :)
public static bool Map(string str) => str switch
{
"true" => true,