Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 6653072

Browse files
committed
fixed typo
1 parent f0cdf44 commit 6653072

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

packages/core/src/state/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class State<ValueType = any> {
7474

7575
/**
7676
* Assigns a new value to the State
77-
* and rerenders all subscribed Components.
77+
* and re-renders all subscribed Components.
7878
*
7979
* [Learn more..](https://agile-ts.org/docs/core/state/properties#value)
8080
*

packages/react/src/core/hocs/AgileHOC.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ComponentClass } from 'react';
1+
import React from 'react';
22
import Agile, {
33
State,
44
ComponentSubscriptionContainer,
@@ -25,11 +25,15 @@ import { logCodeManager } from '../../logCodeManager';
2525
* @param deps - Agile Sub Instances to be bound to the Class Component.
2626
* @param agileInstance - Instance of Agile the React Component belongs to.
2727
*/
28-
export function AgileHOC(
29-
reactComponent: ComponentClass<any, any>,
30-
deps: DepsType,
28+
export function AgileHOC<
29+
ComponentProps,
30+
Deps extends DepsType,
31+
ComponentPropsWithDeps = ComponentProps & DepProps<Deps>
32+
>(
33+
reactComponent: React.ComponentClass<ComponentProps, any>,
34+
deps: Deps,
3135
agileInstance?: Agile
32-
): ComponentClass<any, any> {
36+
): React.ComponentClass<ComponentProps, any> {
3337
let depsWithoutIndicator: Array<Observer> = [];
3438
let depsWithIndicator: DepsWithIndicatorType;
3539

@@ -81,11 +85,11 @@ export function AgileHOC(
8185
* @param depsWithIndicator - Dependencies that have a unique key/name indicator.
8286
*/
8387
const createHOC = (
84-
ReactComponent: ComponentClass<any, any>,
88+
ReactComponent: React.ComponentClass<any, any>,
8589
agileInstance: Agile,
8690
depsWithoutIndicator: Array<Observer>,
8791
depsWithIndicator: DepsWithIndicatorType
88-
): ComponentClass<any, any> => {
92+
): React.ComponentClass<any, any> => {
8993
return class extends ReactComponent {
9094
public agileInstance: Agile;
9195
public waitForMount: boolean;
@@ -252,3 +256,11 @@ export type DepsType =
252256
// | SubscribableAgileInstancesType; // Not allowed because each passed Agile Instance is detect as object and will run through 'formatDepsWithIndicator'
253257

254258
type DepsWithIndicatorType = { [key: string]: Observer };
259+
260+
export type DepProps<T extends DepsType> = {
261+
[K in keyof T]: T[K] extends State<infer U> | Observer<infer U>
262+
? U
263+
: T[K] extends Collection<infer U>
264+
? U[]
265+
: never;
266+
};

packages/react/src/core/hooks/useBaseAgile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Agile, {
88
SubscriptionContainerKeyType,
99
RegisterSubscriptionConfigInterface,
1010
} from '@agile-ts/core';
11-
import { useIsomorphicLayoutEffect } from '../../util';
11+
import { useIsomorphicLayoutEffect } from '../../utils';
1212
import { logCodeManager } from '../../logCodeManager';
1313

1414
/**

packages/react/src/event/hooks/useEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Event, EventCallbackFunction } from '@agile-ts/event'; // When only importing the types the "Can't resolve '@agile-ts/event'" error doesn't occur
2-
import { useIsomorphicLayoutEffect } from '../../util';
2+
import { useIsomorphicLayoutEffect } from '../../utils';
33
import { eventPackage } from '../eventPackage';
44
import { logCodeManager } from '../../logCodeManager';
55
import { BaseAgileHookConfigInterface, useBaseAgile } from '../../core';
File renamed without changes.

0 commit comments

Comments
 (0)