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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: get route info function #289

Merged
merged 2 commits into from
Aug 18, 2021

Conversation

sarkaaa
Copy link
Contributor

@sarkaaa sarkaaa commented Aug 17, 2021

This PR implements a helper function for getting route info.

How to use:

  1. Import a helper function (and route info props):
import { getRouteInfo, RouteInfoResultProps } from "../src/helperFunctions";
  1. Set useState hook for data from mapy.cz API:
const [routeInfo, setRouteInfo] = useState<null | RouteInfoResultProps>(null);
  1. Call the helper function:
const fetchRouteInfo = useCallback(async () => {
  const info = await getRouteInfo(coords, params as any);
  setRouteInfo(info);
}, []);
  1. Don't forget set useEffect function:
useEffect(() => {
  fetchRouteInfo();
}, []);
  1. Tada. 馃帀 Route info is set in routeInfo const and you can use it now.

鈿狅笍 CI issues:
I'm getting some CI issues here at GitHub. When I tried run npm run predeploy locally, I'm not getting any error (I'm locally using the same version of npm and nodejs). Honestly, I don't understand the error message from codeclimate, I've noticed that other functions in this project have more lines than mine and they pass ok. Could you take a look at it, please? 馃檹

@kolebjak
Copy link
Owner

@sarkaaa You missed some imports, fixed it for you and merging.

@kolebjak
Copy link
Owner

Thank you for your contribution, love your work 馃槉

@kolebjak kolebjak merged commit c2228e0 into kolebjak:master Aug 18, 2021
@sarkaaa
Copy link
Contributor Author

sarkaaa commented Aug 18, 2021

@kolebjak Oh, I know where was an error. 馃槵 I did a mistake in the commit process. Thanks for the fixing and merging! 馃槉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants