Skip to content

Commit

Permalink
Bump react-sweet-state (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogasparin authored Dec 21, 2020
1 parent 8e47eee commit bcc8015
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 35 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"lodash.debounce": "^4.0.8",
"lodash.noop": "^3.0.1",
"path-to-regexp": "^1.7.0",
"react-sweet-state": "^2.3.1",
"react-sweet-state": "^2.5.1",
"tslib": "^1.9.3",
"url-parse": "^1.4.5"
},
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/unit/controllers/router-store/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ describe('SPA Router store', () => {
routes: any[],
initialLocation: string
): Promise<any> => {
let historyPush = (path: string) => path;
let historyPush = (path: string) => {
path;
};

mount(
<MemoryRouter routes={routes} location={initialLocation}>
Expand Down
7 changes: 3 additions & 4 deletions src/controllers/redirect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ class Redirector extends Component<RedirectorProps> {

export const Redirect = (props: RedirectProps) => (
<RouterSubscriber>
{(
{ location }: { location: RouterState['location'] },
actions: RouterActionsType
) => <Redirector actions={actions} location={location} {...props} />}
{({ location }, actions) => (
<Redirector actions={actions} location={location} {...props} />
)}
</RouterSubscriber>
);
4 changes: 1 addition & 3 deletions src/controllers/router-actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { RouterActionsSubscriber } from '../router-store';
import { EntireRouterState, RouterActionsType } from '../router-store/types';

type Props = {
children: (
actions: BoundActions<EntireRouterState, RouterActionsType>
) => ReactNode;
children: (actions: RouterActionsType) => ReactNode;
};

export const RouterActions = ({ children }: Props) => (
Expand Down
27 changes: 20 additions & 7 deletions src/controllers/router-store/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';

import { ActionAny as Action } from 'react-sweet-state';
import { Action, BoundActions } from 'react-sweet-state';

import {
BrowserHistory,
Expand All @@ -16,7 +16,7 @@ import {
Route,
Routes,
} from '../../common/types';
import { MemoryHistory } from 'history';
import { MemoryHistory, UnregisterCallback } from 'history';

type PublicStateProperties = {
basePath: string;
Expand Down Expand Up @@ -69,9 +69,17 @@ type PrivateRouterActions = {
bootstrapStoreUniversal: (
initialState: UniversalRouterContainerProps
) => RouterAction;
requestRouteResources: () => RouterAction;
requestRouteResources: () => Action<
EntireRouterState,
AllRouterActions,
Promise<unknown[]>
>;
listen: () => RouterAction;
getContext: () => RouterAction;
getContext: () => Action<
EntireRouterState,
AllRouterActions,
{ query: Query; route: Route; match: Match }
>;
updateQueryParam: (
params: {
[key: string]: string | undefined;
Expand All @@ -93,8 +101,10 @@ type PublicRouterActions = {
replaceTo: (route: Route, attributes?: ToAttributes) => RouterAction;
goBack: () => RouterAction;
goForward: () => RouterAction;
registerBlock: (blocker: HistoryBlocker | any) => RouterAction;
getBasePath: () => RouterAction;
registerBlock: (
blocker: HistoryBlocker | any
) => Action<EntireRouterState, AllRouterActions, UnregisterCallback>;
getBasePath: () => Action<EntireRouterState, AllRouterActions, string>;
};

export type AllRouterActions = PrivateRouterActions & PublicRouterActions;
Expand All @@ -103,7 +113,10 @@ export type AllRouterActions = PrivateRouterActions & PublicRouterActions;
* Public API
*/
export type RouterState = PublicStateProperties;
export type RouterActionsType = PublicRouterActions;
export type RouterActionsType = BoundActions<
EntireRouterState,
PublicRouterActions
>;
export type RouterActionPush = RouterActionsType['push'];
export type RouterActionReplace = RouterActionsType['replace'];
export type RouterSubscriberProps = {
Expand Down
13 changes: 2 additions & 11 deletions src/controllers/subscribers/route/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import React, { ReactNode } from 'react';

import { BoundActions } from 'react-sweet-state';

import { RouterSubscriber as BaseRouterSubscriber } from '../../router-store';
import {
EntireRouterState,
RouterActionsType,
RouterState,
} from '../../router-store/types';
import { RouterActionsType, RouterState } from '../../router-store/types';

type Props = {
children: (
state: RouterState,
actions: BoundActions<EntireRouterState, RouterActionsType>
) => ReactNode;
children: (state: RouterState, actions: RouterActionsType) => ReactNode;
};

export const RouterSubscriber = ({ children }: Props) => (
Expand Down
6 changes: 1 addition & 5 deletions src/types.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ type AllRouterActions = {|
|};

// eslint-disable-next-line no-use-before-define
export type RouterAction = Action<
EntireRouterState,
ContainerProps,
AllRouterActions
>;
export type RouterAction = Action<EntireRouterState, ContainerProps, *>;

// TODO: DRY out all these different router props if possible
export type RouterProps = {
Expand Down

0 comments on commit bcc8015

Please sign in to comment.