Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save webview history, request body and headers #1

Open
johannbuscail opened this issue Sep 10, 2021 · 0 comments
Open

Save webview history, request body and headers #1

johannbuscail opened this issue Sep 10, 2021 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@johannbuscail
Copy link
Member

Introduction

In the current version, when the web view is reloaded (connection problems or Apple Pay),
We lose all the web view history and if the user was submitting a form, we lose all of it's body.
This leads to a bad user experience

How to solve it ?

We need to create an issue on react-native-webview asking for access to the user's history and request data (body and headers) through navigation events.

Save the history in a global state and when the webview is reloaded, set those values programmatically through the library's props.

If a history exists, use the last URL of the history, otherwise pass a URL.

Example:

interface IHistory {
     url: string
     // all necessary data
     request: {
         headers: {}
         body: {}
     }
}

const [historyState, setHistory] = useState<IHistory[]>();

<Webview
     source={{
       [historyState ? "history" : "url"]: historyState || "mysite.com"
     }}
     onNavigationStateChange={({ history }) => {
         setHistory(history);
     }}
/>
@johannbuscail johannbuscail pinned this issue Sep 15, 2021
@johannbuscail johannbuscail added enhancement New feature or request help wanted Extra attention is needed labels Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant