Skip to content

Commit 3016a78

Browse files
Deprecate UiComponent.getPropKey, replace with keyForProp
1 parent ed04a7c commit 3016a78

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

lib/src/component_declaration/component_base_2.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ abstract class UiComponent2<TProps extends UiProps> extends react.Component2
253253
@override
254254
Map<String, react.PropValidator<TProps>> get propTypes => {};
255255

256+
/// Returns the string key of the [factory] prop accessed in [accessProp], including the namespace if one exists.
257+
///
258+
/// __DEPRECATED__: This method had to be deprecated and replaced with [keyForProp] because of the way
259+
/// that shadowing works in Dart when a top-level function name matches the name of an instance method.
260+
@Deprecated('4.0.0')
261+
String getPropKey(void Function(TProps props) accessProp) => keyForProp(accessProp);
262+
256263
/// Returns the string key of the [factory] prop accessed in [accessProp], including the namespace if one exists.
257264
///
258265
/// Intended for use within [propTypes].
@@ -277,7 +284,7 @@ abstract class UiComponent2<TProps extends UiProps> extends react.Component2
277284
/// }
278285
/// }
279286
/// ```
280-
String getPropKey(void Function(TProps props) accessProp) => prop_key_util.getPropKey(accessProp, typedPropsFactory);
287+
String keyForProp(void Function(TProps props) accessProp) => prop_key_util.getPropKey(accessProp, typedPropsFactory);
281288

282289
// ***************************************************************************
283290
//

test/over_react/component_declaration/builder_integration_tests/component2/constant_required_accessor_integration_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class _$ComponentTestProps extends UiProps {
252252
class ComponentTestComponent extends UiComponent2<ComponentTestProps> {
253253
@override
254254
get propTypes => {
255-
getPropKey((p) => p.requiredAndLengthLimited): (props, info) {
255+
this.getPropKey((p) => p.requiredAndLengthLimited): (props, info) {
256256
final length = props.requiredAndLengthLimited?.length;
257257
if (length != 2) {
258258
return PropError.value(length, info.propName, 'must have a length of 2');

test/over_react/component_declaration/builder_integration_tests/component2/required_accessor_integration_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class _$ComponentTestProps extends UiProps {
256256
class ComponentTestComponent extends UiComponent2<ComponentTestProps> {
257257
@override
258258
get propTypes => {
259-
getPropKey((p) => p.requiredAndLengthLimited): (props, info) {
259+
keyForProp((p) => p.requiredAndLengthLimited): (props, info) {
260260
final length = props.requiredAndLengthLimited?.length;
261261
if (length != 2) {
262262
return PropError.value(length, info.propName, 'must have a length of 2');

web/component2/src/demo_components/prop_validation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class PropTypesTestComponent extends UiComponent2<PropTypesTestProps> {
3333
// This is closer to what it looks like in JS, but might be confusing syntax.
3434
@override
3535
get propTypes => {
36-
getPropKey((p) => p.twoObjects): (props, info) {
36+
keyForProp((p) => p.twoObjects): (props, info) {
3737
final length = props.twoObjects?.length;
3838
if (length != 2) {
3939
return PropError.value(length, info.propName, 'must have a length of 2');

0 commit comments

Comments
 (0)