Skip to content

Commit

Permalink
fix: fix cancel and open actions
Browse files Browse the repository at this point in the history
  • Loading branch information
1fabiopereira committed Jun 20, 2023
1 parent b07b9cf commit 60c9285
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pdf-extractor",
"version": "0.2.1",
"version": "0.2.2",
"description": "This library allows you to extract pdfs file data using matches specifics patterns.",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",
Expand Down Expand Up @@ -108,4 +108,4 @@
"typescript"
]
}
}
}
12 changes: 6 additions & 6 deletions sample/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const App: React.FC = (): JSX.Element => {
setUri(data.uri);
};

const onResult = (data: Transient) => {
setPages(data.pages);
setIsEncrypted(data.isEncrypted);
setUri(data.uri);
setTime(data.duration);
setResult(data.text as string[]);
const onResult = (data: Transient | null) => {
setPages(data?.pages);
setIsEncrypted(data?.isEncrypted);
setUri(data?.uri);
setTime(data?.duration);
setResult(data?.text as string[]);
};

return (
Expand Down
12 changes: 9 additions & 3 deletions src/extractors/core/Extractor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@ export const Extractor: React.FC<ExtractorProps> = memo(
*/
const close = () => {
setVisibility(false);
onResult(null);
};

/**
* Triggers callbacks when password changes
*/
const changePassword = useCallback(() => {
close();
setPassword(value);
}, [value]);
setVisibility(false);

if (value?.length) {
setPassword(value);
} else {
onResult(null);
}
}, [value, onResult]);

/**
* Verifies if needs user interaction to provide password
Expand Down

0 comments on commit 60c9285

Please sign in to comment.