Skip to content

Commit

Permalink
fix: deprecate containerStyle prop
Browse files Browse the repository at this point in the history
  • Loading branch information
gmsgowtham committed Aug 20, 2023
1 parent 26624a7 commit 23b9652
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export default function App() {
textStyle={styles.text}
hljsStyle={hljsStyle}
language="typescript"
scrollViewProps={{
contentContainerStyle: styles.codeContainer,
}}
>
{CODE_STR}
</CodeHighlighter>
Expand All @@ -82,7 +85,6 @@ export default function App() {
const styles = StyleSheet.create({
codeContainer: {
paddingHorizontal: 16,
minWidth: "100%",
},
text: {
fontSize: 16,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-native",
"ios",
"android",
"web",
"code-hightlighter",
"syntax-highlighter"
],
Expand Down
13 changes: 10 additions & 3 deletions src/lib/CodeHighlighter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ import {

export interface CodeHighlighterProps extends SyntaxHighlighterProps {
hljsStyle: ReactStyle;
containerStyle?: StyleProp<ViewStyle>;
textStyle?: StyleProp<TextStyle>;
scrollViewProps?: ScrollViewProps;
/**
* @deprecated, Use scrollViewProps.contentContainerStyle instead
*/
containerStyle?: StyleProp<ViewStyle>;
}

export const CodeHighlighter: FunctionComponent<CodeHighlighterProps> = ({
children,
containerStyle,
textStyle,
hljsStyle,
scrollViewProps,
containerStyle,
...rest
}) => {
const stylesheet: HighlighterStyleSheet = useMemo(
Expand Down Expand Up @@ -75,7 +78,11 @@ export const CodeHighlighter: FunctionComponent<CodeHighlighterProps> = ({
<ScrollView
{...scrollViewProps}
horizontal
contentContainerStyle={[stylesheet.hljs, containerStyle]}
contentContainerStyle={[
stylesheet.hljs,
scrollViewProps?.contentContainerStyle,
containerStyle,
]}
>
<View>{renderNode(rows)}</View>
</ScrollView>
Expand Down

0 comments on commit 23b9652

Please sign in to comment.