Skip to content

Commit 5d4d4d1

Browse files
committed
refactor: get builds with adapters working
1 parent 1d34295 commit 5d4d4d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+52977
-3785
lines changed

Diff for: examples/no-router/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"build": "react-scripts build",
1515
"test": "react-scripts test",
1616
"eject": "react-scripts eject",
17-
"preinstall": "npm link ../../node_modules/react"
17+
"preinstall": "npm link ../../packages/use-query-params/node_modules/react"
1818
},
1919
"eslintConfig": {
2020
"extends": "react-app"

Diff for: examples/reach-router/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"build": "react-scripts build",
2424
"test": "react-scripts test --env=jest-environment-jsdom-sixteen",
2525
"eject": "react-scripts eject",
26-
"preinstall": "npm link ../../node_modules/react"
26+
"preinstall": "npm link ../../packages/use-query-params/node_modules/react"
2727
},
2828
"eslintConfig": {
2929
"extends": "react-app"

Diff for: examples/react-router-5/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
"@types/node": "^11.11.2",
99
"@types/react": "^16.8.7",
1010
"@types/react-dom": "^16.8.2",
11-
"@types/react-router-dom": "^4.3.1",
11+
"@types/react-router-dom": "^5.3.3",
12+
"@types/react-router": "^5.1.13",
1213
"query-string": "^6.12.1",
1314
"react": "^16.8.4",
1415
"react-dom": "^16.8.4",
15-
"react-router-dom": "^4.3.1",
16+
"react-router": "^5.3.3",
17+
"react-router-dom": "^5.3.3",
1618
"react-scripts": "2.1.8",
1719
"typescript": "^3.3.3333",
1820
"use-query-params": "*"
@@ -22,7 +24,7 @@
2224
"build": "react-scripts build",
2325
"test": "react-scripts test",
2426
"eject": "react-scripts eject",
25-
"preinstall": "npm link ../../node_modules/react"
27+
"preinstall": "npm link ../../packages/use-query-params/node_modules/react && npm link ../../packages/use-query-params/node_modules/react-router && npm link ../../packages/use-query-params/node_modules/react-router-dom"
2628
},
2729
"eslintConfig": {
2830
"extends": "react-app"

Diff for: examples/react-router-5/src/UseQueryParamExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const UseQueryParamExample = () => {
2323
const [anyp, setAnyP] = useQueryParam('anyp');
2424
const [arr, setArr] = useQueryParam(
2525
'arr',
26-
withDefault(ArrayParam, [] as (string | null)[])
26+
React.useMemo(() => withDefault(ArrayParam, [] as (string | null)[]), [])
2727
);
2828

2929
// verify we aren't creating new arrays each time

Diff for: examples/react-router-5/src/index.tsx

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { BrowserRouter as Router, Route } from 'react-router-dom';
3+
import { BrowserRouter as Router } from 'react-router-dom';
44
import App from './App';
5-
import {
6-
QueryParamProvider,
7-
ExtendedStringifyOptions,
8-
transformSearchStringJsonSafe,
9-
} from 'use-query-params';
10-
11-
const queryStringifyOptions: ExtendedStringifyOptions = {
12-
transformSearchString: transformSearchStringJsonSafe,
13-
};
5+
import { QueryParamProvider } from 'use-query-params';
6+
import { ReactRouter5Adapter } from 'use-query-params/dist/adapters/react-router-5';
7+
import { parse, stringify } from 'query-string';
148

159
ReactDOM.render(
1610
<Router>
1711
<QueryParamProvider
18-
ReactRouterRoute={Route}
19-
stringifyOptions={queryStringifyOptions}
12+
Adapter={ReactRouter5Adapter}
13+
options={{
14+
enableBatching: true,
15+
parseParams: parse,
16+
stringifyParams: stringify,
17+
}}
2018
>
2119
<App />
2220
</QueryParamProvider>

Diff for: examples/react-router-6/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "react-scripts build",
1919
"test": "react-scripts test",
2020
"eject": "react-scripts eject",
21-
"preinstall": "npm link ../../node_modules/react"
21+
"preinstall": "npm link ../../packages/use-query-params/node_modules/react"
2222
},
2323
"eslintConfig": {
2424
"extends": [

Diff for: examples/website-example/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"@types/node": "^14.14.37",
1010
"@types/react": "^17.0.3",
1111
"@types/react-dom": "^17.0.3",
12-
"@types/react-router-dom": "^5.1.7",
12+
"@types/react-router-dom": "^5.3.3",
1313
"@types/react-syntax-highlighter": "^13.5.0",
1414
"nanoid": "^3.1.22",
1515
"query-string": "^7.0.0",
1616
"react": "^17.0.2",
1717
"react-dom": "^17.0.2",
18-
"react-router-dom": "^5.2.0",
18+
"react-router-dom": "^5.3.3",
1919
"react-scripts": "4.0.3",
2020
"react-syntax-highlighter": "^15.4.3",
2121
"typescript": "^4.2.3",
@@ -27,7 +27,7 @@
2727
"test": "react-scripts test",
2828
"eject": "react-scripts eject",
2929
"copy-build": "rsync -vaHE --delete ./build/ ../../docs/",
30-
"preinstall": "npm link ../../node_modules/react"
30+
"preinstall": "npm link ../../packages/use-query-params/node_modules/react && npm link ../../packages/use-query-params/node_modules/react-router && npm link ../../packages/use-query-params/node_modules/react-router-dom"
3131
},
3232
"eslintConfig": {
3333
"extends": "react-app"

Diff for: lerna.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2+
"lerna": "latest",
23
"packages": [
3-
"packages/*",
4-
"examples/*"
4+
"packages/*"
55
],
6+
"npmClient": "npm",
67
"version": "independent"
78
}

0 commit comments

Comments
 (0)