Skip to content

Save webview history, request body and headers #1

@johannbuscail

Description

@johannbuscail

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);
     }}
/>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions