Skip to content

Instantly share code, notes, and snippets.

@Nkzn
Created May 12, 2020 02:38
Embed
What would you like to do?
"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