Skip to content

Commit

Permalink
Merge pull request #959 from Workiva/update-note-about-migrator-compa…
Browse files Browse the repository at this point in the history
…nion

FED-3249 Update docs about migrator companion codemod
  • Loading branch information
rmconsole2-wf authored Oct 24, 2024
2 parents f0cbd99 + 7a6eec8 commit d880fa1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions doc/null_safety/null_safe_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ dart pub global run over_react_codemod:null_safety_migrator_companion --yes-to-a
```

This codemod will:
- Add nullability hints to props/state that are defaulted/initialized in class components.
- These hints will cause defaulted/initialized values to be migrated as "late required".
- Add nullability hints to state mixin/class fields
- These hints will cause defaulted/initialized values to be migrated as "late required" (the same thing is done for props in the [required props codemod](#required-props-codemod)).
See our [prop requiredness and nullability](#prop-requiredness-and-nullability) docs for more details on whether you should keep them required following the migration.
- All non-initialized state fields will have optional nullable hints.
- Add nullable hints for callback ref types.
- Add annotations to disable required prop validation for `connect` props. See [`connect` required props migration case](#wrapper-and-connected-components-and-required-props) for more info.

#### Required props codemod

Expand All @@ -63,7 +66,9 @@ as a separate commit before proceeding with the rest of the migration.
This is a two-step process involving two sub-commands:

1. `null_safety_required_props collect` - Collects requiredness data for all OverReact props based on usages in the specified packages and all their transitive dependencies.
1. `null_safety_required_props codemod` - Adds null safety migrator hints to OverReact props using prop requiredness data from 'collect' command.
1. `null_safety_required_props codemod` - Adds null safety migrator hints to OverReact props taking into account:
1. Prop requiredness data from the 'collect' command.
1. If the prop has a default in `defaultProps`, it will get "late required" hints.

Start with the `collect` command, following its help output for instructions:
```shell
Expand Down Expand Up @@ -208,7 +213,7 @@ of the null safety and required props docs for instructions on how to handle the

For connect, either:
- Disable validation using the instructions linked above
- Note: for now, this must be done manually, but we'll be adding a codemod to help do this automatically for `connect`: https://github.com/Workiva/over_react_codemod/issues/295
- Note: The [null safety migrator companion codemod](#companion-codemod) does this automatically for all `connect` props.
- Refactor your component to instead utilize [OverReact Redux hooks](../over_react_redux_documentation.md#hooks),
which avoid this problem by accessing store data and dispatchers directly in the component as opposed to passing it in via props.

Expand Down

0 comments on commit d880fa1

Please sign in to comment.