Skip to content

Commit 3e87cda

Browse files
committed
Use react router for testing application
1 parent 9e45f33 commit 3e87cda

File tree

4 files changed

+122
-13
lines changed

4 files changed

+122
-13
lines changed

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@types/react-dom": "link:../node_modules/@types/react-dom",
2020
"react": "link:../node_modules/react",
2121
"react-dom": "link:../node_modules/react-dom",
22+
"react-router-dom": "^5.2.0",
2223
"react-scripts": "link:../node_modules/react-scripts",
2324
"styled-components": "^5.2.1",
2425
"typed-react-form": "link:..",
@@ -45,4 +46,4 @@
4546
"last 1 safari version"
4647
]
4748
}
48-
}
49+
}

example/src/StyledProblem.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
import { FormInput, useForm } from "typed-react-form";
4+
5+
const Form = styled.form`
6+
background: #0001;
7+
`;
8+
9+
export function StyledForm() {
10+
const form = useForm({ name: "", email: "" });
11+
12+
return (
13+
<Form>
14+
<FormInput form={form} name="name" />
15+
<FormInput form={form} name="email" />
16+
</Form>
17+
);
18+
}

example/src/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import ReactDOM from "react-dom";
55
import App from "./App";
66
import OneOfObjectForm from "./OneOfObjectForm";
77
import OneOfObjectArrayForm from "./OneOfObjectArrayForm";
8+
import { BrowserRouter, Route, Switch } from "react-router-dom";
89

910
function Router() {
10-
switch (window.location.hash) {
11-
case "#object-types":
12-
return <OneOfObjectForm />;
13-
case "#object-types-array":
14-
return <OneOfObjectArrayForm />;
15-
default:
16-
return <App />;
17-
}
11+
return (
12+
<BrowserRouter>
13+
<Switch>
14+
<Route path="/object-types" component={OneOfObjectForm} />
15+
<Route path="/object-types-array" component={OneOfObjectArrayForm} />
16+
<Route path="/" component={App} />
17+
</Switch>
18+
</BrowserRouter>
19+
);
1820
}
1921

2022
ReactDOM.render(<Router />, document.getElementById("root"));

example/yarn.lock

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,13 @@
11461146
dependencies:
11471147
regenerator-runtime "^0.13.4"
11481148

1149+
"@babel/runtime@^7.1.2", "@babel/runtime@^7.12.1":
1150+
version "7.13.10"
1151+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
1152+
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
1153+
dependencies:
1154+
regenerator-runtime "^0.13.4"
1155+
11491156
"@babel/runtime@^7.10.5":
11501157
version "7.12.13"
11511158
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.13.tgz#0a21452352b02542db0ffb928ac2d3ca7cb6d66d"
@@ -5167,6 +5174,18 @@ hex-color-regex@^1.1.0:
51675174
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
51685175
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
51695176

5177+
history@^4.9.0:
5178+
version "4.10.1"
5179+
resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
5180+
integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==
5181+
dependencies:
5182+
"@babel/runtime" "^7.1.2"
5183+
loose-envify "^1.2.0"
5184+
resolve-pathname "^3.0.0"
5185+
tiny-invariant "^1.0.2"
5186+
tiny-warning "^1.0.0"
5187+
value-equal "^1.0.1"
5188+
51705189
hmac-drbg@^1.0.0:
51715190
version "1.0.1"
51725191
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
@@ -5176,7 +5195,7 @@ hmac-drbg@^1.0.0:
51765195
minimalistic-assert "^1.0.0"
51775196
minimalistic-crypto-utils "^1.0.1"
51785197

5179-
hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0:
5198+
hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0:
51805199
version "3.3.2"
51815200
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
51825201
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
@@ -5861,6 +5880,11 @@ is-wsl@^2.1.1:
58615880
dependencies:
58625881
is-docker "^2.0.0"
58635882

5883+
5884+
version "0.0.1"
5885+
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
5886+
integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=
5887+
58645888
[email protected], isarray@^1.0.0, isarray@~1.0.0:
58655889
version "1.0.0"
58665890
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -6725,7 +6749,7 @@ loglevel@^1.6.8:
67256749
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197"
67266750
integrity sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw==
67276751

6728-
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0:
6752+
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
67296753
version "1.4.0"
67306754
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
67316755
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
@@ -6920,6 +6944,14 @@ mimic-fn@^2.1.0:
69206944
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
69216945
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==
69226946

6947+
mini-create-react-context@^0.4.0:
6948+
version "0.4.1"
6949+
resolved "https://registry.yarnpkg.com/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz#072171561bfdc922da08a60c2197a497cc2d1d5e"
6950+
integrity sha512-YWCYEmd5CQeHGSAKrYvXgmzzkrvssZcuuQDDeqkT+PziKGMgE+0MCCtcKbROzocGBG1meBLl2FotlRwf4gAzbQ==
6951+
dependencies:
6952+
"@babel/runtime" "^7.12.1"
6953+
tiny-warning "^1.0.3"
6954+
69236955
69246956
version "0.9.0"
69256957
resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.0.tgz#47f2cf07aa165ab35733b1fc97d4c46c0564339e"
@@ -7674,6 +7706,13 @@ [email protected]:
76747706
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
76757707
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=
76767708

7709+
path-to-regexp@^1.7.0:
7710+
version "1.8.0"
7711+
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
7712+
integrity sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==
7713+
dependencies:
7714+
isarray "0.0.1"
7715+
76777716
path-type@^2.0.0:
76787717
version "2.0.0"
76797718
resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
@@ -8539,7 +8578,7 @@ prompts@^2.0.1:
85398578
kleur "^3.0.3"
85408579
sisteransi "^1.0.5"
85418580

8542-
prop-types@^15.7.2:
8581+
prop-types@^15.6.2, prop-types@^15.7.2:
85438582
version "15.7.2"
85448583
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
85458584
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -8749,11 +8788,40 @@ react-error-overlay@^6.0.7:
87498788
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.8.tgz#474ed11d04fc6bda3af643447d85e9127ed6b5de"
87508789
integrity sha512-HvPuUQnLp5H7TouGq3kzBeioJmXms1wHy9EGjz2OURWBp4qZO6AfGEcnxts1D/CbwPLRAgTMPCEgYhA3sEM4vw==
87518790

8752-
react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4:
8791+
react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4:
87538792
version "16.13.1"
87548793
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
87558794
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
87568795

8796+
react-router-dom@^5.2.0:
8797+
version "5.2.0"
8798+
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.2.0.tgz#9e65a4d0c45e13289e66c7b17c7e175d0ea15662"
8799+
integrity sha512-gxAmfylo2QUjcwxI63RhQ5G85Qqt4voZpUXSEqCwykV0baaOTQDR1f0PmY8AELqIyVc0NEZUj0Gov5lNGcXgsA==
8800+
dependencies:
8801+
"@babel/runtime" "^7.1.2"
8802+
history "^4.9.0"
8803+
loose-envify "^1.3.1"
8804+
prop-types "^15.6.2"
8805+
react-router "5.2.0"
8806+
tiny-invariant "^1.0.2"
8807+
tiny-warning "^1.0.0"
8808+
8809+
8810+
version "5.2.0"
8811+
resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.2.0.tgz#424e75641ca8747fbf76e5ecca69781aa37ea293"
8812+
integrity sha512-smz1DUuFHRKdcJC0jobGo8cVbhO3x50tCL4icacOlcwDOEQPq4TMqwx3sY1TP+DvtTgz4nm3thuo7A+BK2U0Dw==
8813+
dependencies:
8814+
"@babel/runtime" "^7.1.2"
8815+
history "^4.9.0"
8816+
hoist-non-react-statics "^3.1.0"
8817+
loose-envify "^1.3.1"
8818+
mini-create-react-context "^0.4.0"
8819+
path-to-regexp "^1.7.0"
8820+
prop-types "^15.6.2"
8821+
react-is "^16.6.0"
8822+
tiny-invariant "^1.0.2"
8823+
tiny-warning "^1.0.0"
8824+
87578825
"react-scripts@link:../node_modules/react-scripts":
87588826
version "0.0.0"
87598827
uid ""
@@ -9037,6 +9105,11 @@ resolve-from@^4.0.0:
90379105
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
90389106
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
90399107

9108+
resolve-pathname@^3.0.0:
9109+
version "3.0.0"
9110+
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-3.0.0.tgz#99d02224d3cf263689becbb393bc560313025dcd"
9111+
integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==
9112+
90409113
90419114
version "3.1.2"
90429115
resolved "https://registry.yarnpkg.com/resolve-url-loader/-/resolve-url-loader-3.1.2.tgz#235e2c28e22e3e432ba7a5d4e305c59a58edfc08"
@@ -10067,6 +10140,16 @@ timsort@^0.3.0:
1006710140
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
1006810141
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
1006910142

10143+
tiny-invariant@^1.0.2:
10144+
version "1.1.0"
10145+
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875"
10146+
integrity sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw==
10147+
10148+
tiny-warning@^1.0.0, tiny-warning@^1.0.3:
10149+
version "1.0.3"
10150+
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
10151+
integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==
10152+
1007010153
tmp@^0.0.33:
1007110154
version "0.0.33"
1007210155
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
@@ -10441,6 +10524,11 @@ validate-npm-package-license@^3.0.1:
1044110524
spdx-correct "^3.0.0"
1044210525
spdx-expression-parse "^3.0.0"
1044310526

10527+
value-equal@^1.0.1:
10528+
version "1.0.1"
10529+
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-1.0.1.tgz#1e0b794c734c5c0cade179c437d356d931a34d6c"
10530+
integrity sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==
10531+
1044410532
vary@~1.1.2:
1044510533
version "1.1.2"
1044610534
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"

0 commit comments

Comments
 (0)