-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Field): convert to TypeScript, impove docs and tests
- Loading branch information
xuanji.w
committed
Jan 31, 2024
1 parent
63dec10
commit 64ac384
Showing
16 changed files
with
432 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ import { Input, Button, Field } from '@alifd/next'; | |
import { combineReducers, createStore } from 'redux'; | ||
import { Provider, connect } from 'react-redux'; | ||
|
||
function formReducer(state = { email: '[email protected]' }, action) { | ||
function formReducer( | ||
state = { email: '[email protected]' }, | ||
action: { type: string; payload: { [key: string]: string } } | ||
) { | ||
switch (action.type) { | ||
case 'save_fields': | ||
return { | ||
|
@@ -17,8 +20,13 @@ function formReducer(state = { email: '[email protected]' }, action) { | |
} | ||
} | ||
|
||
class Demo extends React.Component { | ||
componentWillReceiveProps(nextProps) { | ||
interface DemoProps { | ||
email: string; | ||
dispatch: (action: { type: string; payload: { [key: string]: string } }) => void; | ||
} | ||
|
||
class Demo extends React.Component<DemoProps> { | ||
componentWillReceiveProps(nextProps: DemoProps) { | ||
this.field.setValues({ | ||
email: nextProps.email, | ||
newlen: nextProps.email.length, | ||
|
@@ -71,7 +79,7 @@ class Demo extends React.Component { | |
} | ||
} | ||
|
||
const ReduxDemo = connect(state => { | ||
const ReduxDemo = connect((state: { formReducer: { email: string } }) => { | ||
return { | ||
email: state.formReducer.email, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.