Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. # JSX props should not use arrow functions
  2.  
  3.  
  4. react-router-navigation-prompt
  5. ```
  6. ./src/components/FormDragAndDropArea/index.tsx
  7. Line 61: JSX props should not use arrow functions react/jsx-no-bind
  8. ```
  9.  
  10. Error is here!!
  11.  
  12. ```ts
  13. <NavigationPrompt
  14. when={(currentLocation, nextLocation) => { //here!!
  15. if(!nextLocation) return false;
  16. setState((prev) => ({...prev, pathname: nextLocation.pathname}));
  17. return !nextLocation.pathname.startsWith(currentLocation.pathname) && !!formRows.length && locationState.pathname !== nextLocation.pathname
  18. }
  19. }
  20. >
  21. ```
  22.  
  23.  
  24. Fix error with useCallback
  25.  
  26. ```ts
  27. const whenCallback = useCallback((currentLocation, nextLocation) => {
  28. if(!nextLocation) return false;
  29. setState((prev) => ({...prev, pathname: nextLocation.pathname}));
  30. return !nextLocation.pathname.startsWith(currentLocation.pathname) && !!formRows.length && locationState.pathname !== nextLocation.pathname
  31. }, [formRows.length, locationState.pathname]);
  32. return (
  33. <div className={classes.pageContainer}>
  34. <div className={classes.PartList}>
  35. <AppSettingsFormPartSwitcher />
  36. <NavigationPrompt when={whenCallback} > // here!
  37. {({isActive, onConfirm, onCancel}) => (
  38. <MoveFormComponentDialog
  39. isActive={isActive}
  40. onConfirm={onConfirm}
  41. onCancel={onCancel}
  42. dialogId={"comfirmStoreFormRows"}
  43. line={11}
  44. index={1}
  45. length={formRows.length}
  46. locationState={locationState}
  47. />)}
  48. </NavigationPrompt>
  49. </div>
  50. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement