Skip to content

Commit 344a3a4

Browse files
committed
getState type bug
1 parent 613cc27 commit 344a3a4

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

fsdf.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[In my first and latest post](https://dev.to/sametweb/how-to-create-multi-step-forms-in-react-3km4), I introduced my `react-step-builder` package for creating multi-step front-end interfaces with an example registration form.
2+
3+
Recently, I was working on adding TypeScript support to my project. Along with the TypeScript support, I also made some changes to the API of the library. I would like to mention those changes in this post for those who are familiar with the previous version and would like to upgrade to the TypeScript version.
4+
5+
## What changed?
6+
7+
| v1.1.5 | v.2.0.x | Reason |
8+
| --------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
9+
| `props.current` | N/A | no real use case |
10+
| `props.getState(key)` | `props.getState(key, defaultValue)` | Before initiating a state value, getState returns the default value you set. For inputs, pass an empty string. For checkbox values, pass a boolean value. |

src/lib-ts/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ type AllSteps = { order: number; title: string }[];
4343
type OrderCheckFn = () => boolean;
4444
type MoveFn = () => void;
4545
type JumpFn = (step: number) => void;
46-
type GetState = (
47-
key: keyof State,
48-
defaultValue: State[keyof State],
49-
) => InputValue | CheckboxValue;
46+
type GetState = (key: keyof State, defaultValue: State[keyof State]) => any;
5047
type SetState = (key: keyof State, value: State[keyof State]) => void;
5148
type HandleChange = (event: EventType) => void;
5249

0 commit comments

Comments
 (0)