Skip to content
Merged
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
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE/advanced-cheatsheet.md

This file was deleted.

19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/basic-cheatsheet.md

This file was deleted.

11 changes: 0 additions & 11 deletions .github/ISSUE_TEMPLATE/general-react-ts-question.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE/hoc-cheatsheet.md

This file was deleted.

6 changes: 0 additions & 6 deletions .github/pull_request_template.md

This file was deleted.

17 changes: 0 additions & 17 deletions .github/stale.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflows/mlc_config.json

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ Note that for React < 18, the function signature of `useCallback` typed argument
```ts
function useCallback<T extends (...args: any[]) => any>(
callback: T,
deps: DependencyList
deps: DependencyList,
): T;
```

Expand Down Expand Up @@ -298,7 +298,7 @@ type ACTIONTYPE =

function reducer(
state: typeof initialState,
action: ACTIONTYPE
action: ACTIONTYPE,
): typeof initialState {
switch (action.type) {
case "increment":
Expand Down Expand Up @@ -353,7 +353,7 @@ In most cases, type inference for useReducer should work reliably. When inferenc
```tsx
const [state, dispatch] = useReducer<typeof initialState, [ACTIONTYPE]>(
reducer,
initialState
initialState,
);
```

Expand All @@ -372,7 +372,7 @@ function DelayedEffect(props: { timerMs: number }) {
setTimeout(() => {
/* do stuff */
}, timerMs),
[timerMs]
[timerMs],
);
// bad example! setTimeout implicitly returns a number
// because the arrow function body isn't wrapped in curly braces
Expand Down Expand Up @@ -730,7 +730,7 @@ Here are a few ways in which you can annotate `getDerivedStateFromProps`
class Comp extends React.Component<Props, State> {
static getDerivedStateFromProps(
props: Props,
state: State
state: State,
): Partial<State> | null {
//
}
Expand Down Expand Up @@ -1037,7 +1037,7 @@ Here are a few ways in which you can annotate `getDerivedStateFromProps`
class Comp extends React.Component<Props, State> {
static getDerivedStateFromProps(
props: Props,
state: State
state: State,
): Partial<State> | null {
//
}
Expand Down Expand Up @@ -1321,7 +1321,7 @@ const useCurrentUser = () => {

if (!currentUserContext) {
throw new Error(
"useCurrentUser has to be used within <CurrentUserContext>"
"useCurrentUser has to be used within <CurrentUserContext>",
);
}

Expand Down Expand Up @@ -1357,7 +1357,7 @@ Another option is to use an empty object as default value and cast it to the exp

```tsx
const CurrentUserContext = createContext<CurrentUserContextType>(
{} as CurrentUserContextType
{} as CurrentUserContextType,
);
```

Expand Down Expand Up @@ -1464,12 +1464,12 @@ interface Props {
export const FancyButton = forwardRef(
(
props: Props,
ref: Ref<HTMLButtonElement> // <-- explicit immutable ref type
ref: Ref<HTMLButtonElement>, // <-- explicit immutable ref type
) => (
<button ref={ref} className="MyClassName" type={props.type}>
{props.children}
</button>
)
),
);
```

Expand Down Expand Up @@ -1532,7 +1532,7 @@ For true `forwardRef` behavior with generics, extend the module declaration:
// Redeclare forwardRef to support generics
declare module "react" {
function forwardRef<T, P = {}>(
render: (props: P, ref: React.Ref<T>) => React.ReactElement | null
render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,
): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
}

Expand All @@ -1546,7 +1546,7 @@ interface ClickableListProps<T> {

function ClickableListInner<T>(
props: ClickableListProps<T>,
ref: ForwardedRef<HTMLUListElement>
ref: ForwardedRef<HTMLUListElement>,
) {
return (
<ul ref={ref}>
Expand All @@ -1571,7 +1571,7 @@ If you need both generic support and proper forwardRef behavior with full type i
// Add to your type definitions (e.g. in `index.d.ts` file)
interface ForwardRefWithGenerics extends React.FC<WithForwardRefProps<Option>> {
<T extends Option>(
props: WithForwardRefProps<T>
props: WithForwardRefProps<T>,
): ReturnType<React.FC<WithForwardRefProps<T>>>;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/basic/getting-started/class-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Here are a few ways in which you can annotate `getDerivedStateFromProps`
class Comp extends React.Component<Props, State> {
static getDerivedStateFromProps(
props: Props,
state: State
state: State,
): Partial<State> | null {
//
}
Expand Down
4 changes: 2 additions & 2 deletions docs/basic/getting-started/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const useCurrentUser = () => {

if (!currentUserContext) {
throw new Error(
"useCurrentUser has to be used within <CurrentUserContext>"
"useCurrentUser has to be used within <CurrentUserContext>",
);
}

Expand Down Expand Up @@ -139,7 +139,7 @@ Another option is to use an empty object as default value and cast it to the exp

```tsx
const CurrentUserContext = createContext<CurrentUserContextType>(
{} as CurrentUserContextType
{} as CurrentUserContextType,
);
```

Expand Down
10 changes: 5 additions & 5 deletions docs/basic/getting-started/forward-create-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ interface Props {
export const FancyButton = forwardRef(
(
props: Props,
ref: Ref<HTMLButtonElement> // <-- explicit immutable ref type
ref: Ref<HTMLButtonElement>, // <-- explicit immutable ref type
) => (
<button ref={ref} className="MyClassName" type={props.type}>
{props.children}
</button>
)
),
);
```

Expand Down Expand Up @@ -160,7 +160,7 @@ For true `forwardRef` behavior with generics, extend the module declaration:
// Redeclare forwardRef to support generics
declare module "react" {
function forwardRef<T, P = {}>(
render: (props: P, ref: React.Ref<T>) => React.ReactElement | null
render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,
): (props: P & React.RefAttributes<T>) => React.ReactElement | null;
}

Expand All @@ -174,7 +174,7 @@ interface ClickableListProps<T> {

function ClickableListInner<T>(
props: ClickableListProps<T>,
ref: ForwardedRef<HTMLUListElement>
ref: ForwardedRef<HTMLUListElement>,
) {
return (
<ul ref={ref}>
Expand All @@ -199,7 +199,7 @@ If you need both generic support and proper forwardRef behavior with full type i
// Add to your type definitions (e.g. in `index.d.ts` file)
interface ForwardRefWithGenerics extends React.FC<WithForwardRefProps<Option>> {
<T extends Option>(
props: WithForwardRefProps<T>
props: WithForwardRefProps<T>,
): ReturnType<React.FC<WithForwardRefProps<T>>>;
}

Expand Down
8 changes: 4 additions & 4 deletions docs/basic/getting-started/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Note that for React < 18, the function signature of `useCallback` typed argument
```ts
function useCallback<T extends (...args: any[]) => any>(
callback: T,
deps: DependencyList
deps: DependencyList,
): T;
```

Expand Down Expand Up @@ -95,7 +95,7 @@ type ACTIONTYPE =

function reducer(
state: typeof initialState,
action: ACTIONTYPE
action: ACTIONTYPE,
): typeof initialState {
switch (action.type) {
case "increment":
Expand Down Expand Up @@ -150,7 +150,7 @@ In most cases, type inference for useReducer should work reliably. When inferenc
```tsx
const [state, dispatch] = useReducer<typeof initialState, [ACTIONTYPE]>(
reducer,
initialState
initialState,
);
```

Expand All @@ -169,7 +169,7 @@ function DelayedEffect(props: { timerMs: number }) {
setTimeout(() => {
/* do stuff */
}, timerMs),
[timerMs]
[timerMs],
);
// bad example! setTimeout implicitly returns a number
// because the arrow function body isn't wrapped in curly braces
Expand Down
Loading
Loading