Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare module "react-app-location" {
import React from "react";
import { Schema } from "yup";
import { Link, Route } from "react-router-dom";
import { LocationDescriptor } from "history";

export type YupParams = Record<string, Schema>;

export default class RouterLocation {
constructor(
path: string,
pathParamDefs: YupParams | null = {},
queryStringParamDefs: YupParams | null = {}
);

path: string;

toRoute(
renderOptions: { component?; render?; children?; invalid },
exact: boolean = false,
strict: boolean = false,
sensitive: boolean = false
): Route;

toLink(children: React.ReactNode, params: YupParams, props = {}): Link;

toUrl(params?: object): string;

parseLocationParams(
location?: LocationDescriptor | Location,
match?: object
): object | null;

isValidParams(params?: object): boolean;
}
}
89 changes: 59 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.2.0",
"description": "A package to avoid repetition with Routes, Links and URLs, and reduce boilerplate with location param parsing in React Apps",
"main": "./dist/Location.js",
"types": "./index.d.ts",
"repository": "https://github.com/bradstiff/react-app-location.git",
"scripts": {
"start": "webpack-dev-server --mode development",
Expand Down Expand Up @@ -52,6 +53,10 @@
"yup": "^0.26.3"
},
"dependencies": {
"@types/history": "^4.7.4",
"@types/react": "^16.9.18",
"@types/react-router-dom": "^5.1.3",
"@types/yup": "^0.26.27",
"app-location": "^1.1.1",
"querystringify": "^2.0.0",
"warning": "^4.0.2"
Expand Down