Skip to content

Instantly share code, notes, and snippets.

@Nkzn
Created May 12, 2020 02:38
Show Gist options
  • Save Nkzn/bbd5735bc1be89d85e605224c28e9281 to your computer and use it in GitHub Desktop.
Save Nkzn/bbd5735bc1be89d85e605224c28e9281 to your computer and use it in GitHub Desktop.
"accessibilityRole: 'heading'" with TypeScript
import React from 'react';
import { StyleProp, TextStyle, StyleSheet } from 'react-native';
import { Headline as PaperHeadline } from 'react-native-paper';
export const Headline = (props: {
style?: StyleProp<TextStyle>;
children: string;
}) =>
React.cloneElement(
<PaperHeadline style={StyleSheet.flatten([styles.headline, props.style])}>
{props.children}
</PaperHeadline>,
{
accessibilityRole: 'heading',
'aria-level': '2',
}
);
const styles = StyleSheet.create({
headline: {
fontSize: 24,
marginVertical: 16,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment