Skip to content

Commit

Permalink
feat: add umi/prompt (umijs#1267)
Browse files Browse the repository at this point in the history
e.g.

```js
import Prompt from 'umi/prompt';

export default () => {
  return (
    <>
      <h1>Prompt</h1>
      <Prompt
        when={true}
        message={(location) => {
          return window.confirm(`confirm to leave to ${location.pathname}?`);
        }}
      />
    </>
  );
}

```
  • Loading branch information
sorrycc authored Oct 17, 2018
1 parent d9717c3 commit 749898b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
26 changes: 25 additions & 1 deletion docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,31 @@ import Redirect from 'umi/redirect';
<Redirect to="/login" />
```

Detail: [https://reacttraining.com/react-router/web/api/Redirect](https://reacttraining.com/react-router/web/api/Redirect)
See: [https://reacttraining.com/react-router/web/api/Redirect](https://reacttraining.com/react-router/web/api/Redirect)

### umi/prompt

Example.

```js
import Prompt from 'umi/prompt';

export default () => {
return (
<>
<h1>Prompt</h1>
<Prompt
when={true}
message={(location) => {
return window.confirm(`confirm to leave to ${location.pathname}?`);
}}
/>
</>
);
}
```

See:[https://reacttraining.com/react-router/web/api/Prompt](https://reacttraining.com/react-router/web/api/Prompt)

### umi/withRouter

Expand Down
24 changes: 24 additions & 0 deletions docs/zh/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ import Redirect from 'umi/redirect';

详见:[https://reacttraining.com/react-router/web/api/Redirect](https://reacttraining.com/react-router/web/api/Redirect)

### umi/prompt

例子:

```js
import Prompt from 'umi/prompt';

export default () => {
return (
<>
<h1>Prompt</h1>
<Prompt
when={true}
message={(location) => {
return window.confirm(`confirm to leave to ${location.pathname}?`);
}}
/>
</>
);
}
```

详见:[https://reacttraining.com/react-router/web/api/Prompt](https://reacttraining.com/react-router/web/api/Prompt)

### umi/withRouter

详见:[https://reacttraining.com/react-router/web/api/withRouter](https://reacttraining.com/react-router/web/api/withRouter)
Expand Down
1 change: 1 addition & 0 deletions packages/umi-build-dev/src/plugins/afwebpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function(api) {
.set('umi/dynamic', join(process.env.UMI_DIR, 'lib/dynamic.js'))
.set('umi/navlink', join(process.env.UMI_DIR, 'lib/navlink.js'))
.set('umi/redirect', join(process.env.UMI_DIR, 'lib/redirect.js'))
.set('umi/prompt', join(process.env.UMI_DIR, 'lib/prompt.js'))
.set('umi/router', join(process.env.UMI_DIR, 'lib/router.js'))
.set('umi/withRouter', join(process.env.UMI_DIR, 'lib/withRouter.js'))
.set(
Expand Down
2 changes: 2 additions & 0 deletions packages/umi/src/prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { Prompt } from 'react-router-dom';
export default Prompt;

0 comments on commit 749898b

Please sign in to comment.