Skip to content

Commit e0cae0d

Browse files
author
Igor Canedo
committed
changing loadAttributes to receive an object
1 parent 47d634e commit e0cae0d

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/components/DraftJsText.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ const DraftJsText = (props: DraftJsTextPropsType): any => {
2020
let textElements = props.text;
2121

2222
if (textElements) {
23-
textElements = loadAttributes(
24-
props.text,
25-
props.customStyles,
26-
props.inlineStyles,
27-
props.entityRanges,
28-
props.entityMap,
29-
props.navigate,
30-
);
23+
textElements = loadAttributes({
24+
text: props.text,
25+
customStyles: props.customStyles,
26+
inlineStyles: props.inlineStyles,
27+
entityRanges: props.entityRanges,
28+
entityMap: props.entityMap,
29+
navigate: props.navigate,
30+
});
3131

3232
const customStyle = props.customStyles ? props.customStyles[props.type] : undefined;
3333

src/loadAttributes.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,24 @@ const getItemOnPress = (item: Object, entityMap: Object, navigate: Function) =>
2424
return undefined;
2525
};
2626

27-
const loadAttributes = (
27+
type ParamsType = {
2828
text: string,
2929
customStyles?: Object,
3030
inlineStyles: Array<Object>,
3131
entityRanges: Array<Object>,
3232
entityMap: Object,
33-
navigate?: Function): any => {
33+
navigate?: Function,
34+
};
35+
36+
const loadAttributes = (params: ParamsType): any => {
37+
const {
38+
text,
39+
customStyles,
40+
inlineStyles,
41+
entityRanges,
42+
entityMap,
43+
navigate,
44+
} = params;
3445
const defaultNavigationFn = (url: string) => { Linking.openURL(url); };
3546
const navigateFunction = navigate || defaultNavigationFn;
3647
const elementList = [];

0 commit comments

Comments
 (0)