File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,19 @@ class GoodBye extends React.Component {
2727 }
2828
2929 render ( ) {
30- const { when, children } = this . props ;
30+ const { when, children, conditionalPrompt } = this . props ;
3131 return (
3232 < Fragment >
33- < ReactRouterPrompt when = { when } message = "" />
33+ < ReactRouterPrompt
34+ when = { when }
35+ message = { location => {
36+ if ( typeof conditionalPrompt === 'undefined' || conditionalPrompt ( location ) !== true ) {
37+ return '' ;
38+ }
39+
40+ return true ;
41+ } }
42+ />
3443 < GoodByeContext . Consumer >
3544 { renderProps => children ( { ...renderProps } ) }
3645 </ GoodByeContext . Consumer >
@@ -41,6 +50,7 @@ class GoodBye extends React.Component {
4150
4251GoodBye . propTypes = {
4352 when : PropTypes . bool ,
53+ conditionalPrompt : PropTypes . func ,
4454 alertBeforeUnload : PropTypes . bool ,
4555 alertMessage : PropTypes . string ,
4656 children : PropTypes . func . isRequired ,
You can’t perform that action at this time.
0 commit comments