Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FED-2046 Backpatch disableRequiredPropValidation annotation arg #879

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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# OverReact Changelog

## [4.11.0](https://github.com/Workiva/over_react/compare/4.10.4...4.11.0)
- [#879] Backpatch @Props(disableRequiredPropValidation) annotation arg

## [4.10.4](https://github.com/Workiva/over_react/compare/4.10.3...4.10.4)
- [#853] Allow react 7 and w_flux 3

## [4.10.3](https://github.com/Workiva/over_react/compare/4.10.2...4.10.3)
- [#846] Update internals to prepare for react-dart 7.0.0

Expand Down
45 changes: 42 additions & 3 deletions lib/src/component_declaration/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,46 @@ class Props implements TypedMap {
/// overriding the default of `'${propsClassName}.'`.
@override
final String keyNamespace;
const Props({this.keyNamespace});

/// NOTE: This annotation arg currently does nothing in over_react v4, but exists
/// in order to prepare for the migration to over_react v5 in which missing required
/// props will throw runtime errors.
///
/// ---
///
/// The following is what this arg will do on over_react v5:
///
/// Names of props to opt out of required prop validation for, both statically in the analyzer plugin
/// and at runtime when invoking the builder (only with asserts enabled).
///
/// Useful when you have a wrapper component that sets required prop manually.
///
/// For example:
///
/// ```dart
/// mixin FooProps on UiProps {
/// late String requiredPropAlwaysSetInWrapper;
/// late String requiredPropNotSetInWrapper;
/// }
///
/// UiFactory<FooProps> Foo = uiFunction((props) {
/// // ...
/// }, _$FooConfig);
///
/// @Props(disableRequiredPropValidation: {'requiredPropAlwaysSetInWrapper'})
/// class WrapperProps = UiProps with FooProps, WrapperPropsMixin;
///
/// UiFactory<WrapperProps> Wrapper = uiForwardRef((props, ref) {
/// return (Foo()
/// ..requiredPropAlwaysSetInWrapper = 'foo'
/// ..addProps(props.getPropsToForward(exclude: {WrapperPropsMixin}))
/// ..ref = ref
/// )();
/// }, _$WrapperConfig);
///```
final Set<String> disableRequiredPropValidation;

const Props({this.keyNamespace, this.disableRequiredPropValidation});
}

/// Annotation used with the `over_react` builder to declare a `UiState` mixin for a component.
Expand Down Expand Up @@ -274,7 +313,7 @@ class AbstractComponent2 implements AbstractComponent { // ignore: deprecated_me
///
/// Classes using this annotation must include the abstract `props` getter.
///
/// __Deprecated.__ Use the `@Props()` annotation instead if you need to make use of an annotation argument.
/// __Deprecated.__ Use the `@Props()` annotation instead if you need to make use of an annotation argument.
/// Otherwise, this can be removed completely. Will be removed in the 4.0.0 release of over_react.
@Deprecated('Use the @Props() annotation if you need to make use of an annotation argument. Otherwise, this can be removed completely. Will be removed in the 4.0.0 release of over_react.')
class PropsMixin implements TypedMap {
Expand All @@ -298,7 +337,7 @@ class PropsMixin implements TypedMap {
///
/// Classes using this annotation must include the abstract `state` getter.
///
/// __Deprecated.__ Use the `@State()` annotation instead if you need to make use of an annotation argument.
/// __Deprecated.__ Use the `@State()` annotation instead if you need to make use of an annotation argument.
/// Otherwise, this can be removed completely. Will be removed in the 4.0.0 release of over_react.
@Deprecated('Use the @State() annotation if you need to make use of an annotation argument. Otherwise, this can be removed completely. Will be removed in the 4.0.0 release of over_react.')
class StateMixin implements TypedMap {
Expand Down
Loading