Skip to content

Commit fbcfa15

Browse files
rabbitomjthysell
andauthored
fix: event declartion and handler (#929)
## Description ### Why * 'ReactEvent' is obsolete, it raises error when compiling, change it to 'Action'. * 'eventHandler' is a member of the component, it raises render error without 'this.' ## Screenshots <img width="378" alt="ReactEvent error" src="https://github.com/microsoft/react-native-windows-samples/assets/4596887/35213737-c374-4c0b-8ea4-0da16cb86ae2"> <img width="459" alt="ReactEvent Obsolete" src="https://github.com/microsoft/react-native-windows-samples/assets/4596887/3661add7-508f-4808-b742-190a3c625ad0"> <img width="385" alt="eventHandler not defined" src="https://github.com/microsoft/react-native-windows-samples/assets/4596887/99a9b1c4-4c5e-4bb9-a860-b11da9031a2d"> ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/react-native-windows-samples/pull/929) Co-authored-by: Jon Thysell <jthysell@microsoft.com>
1 parent 722e302 commit fbcfa15

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

docs/native-modules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ namespace NativeModuleSample
155155
}
156156

157157
[ReactEvent]
158-
public ReactEvent<double> AddEvent { get; set; }
158+
public Action<double> AddEvent { get; set; }
159159
}
160160
}
161161
```
@@ -503,12 +503,12 @@ class NativeModuleSample extends Component {
503503
504504
componentDidMount() {
505505
// Subscribing to FancyMath.AddEvent
506-
FancyMathEventEmitter.addListener('AddEvent', eventHandler, this);
506+
FancyMathEventEmitter.addListener('AddEvent', this.eventHandler, this);
507507
}
508508
509509
componentWillUnmount() {
510510
// Unsubscribing from FancyMath.AddEvent
511-
FancyMathEventEmitter.removeListener('AddEvent', eventHandler, this);
511+
FancyMathEventEmitter.removeListener('AddEvent', this.eventHandler, this);
512512
}
513513
514514
eventHandler(result) {

0 commit comments

Comments
 (0)