Closed dirkpostma closed 2 months ago
I think we may need to tweak our default targets
for browserlist so that classes are transformed: https://github.com/callstack/react-native-builder-bob/blob/cc30f7f041869cf0d66e826e02b377363a9af55c/packages/react-native-builder-bob/babel-preset.js#L19
Can you try the babel preset from here and let me know if it works?
https://github.com/callstack/react-native-builder-bob/pull/606
@satya164 I can confirm #606 fixes the issue.
How I tested
@babel/plugin-transform-class-properties
@babel/plugin-transform-classes
@babel/plugin-transform-private-methods
@babel/plugin-transform-private-property-in-object
I applied changes made here to /example/node_modules/react-native-builder-bob/babel-preset.js
re-run the example app, having class MyClass
Result Example app runs without issues.
Description
Typescript classes in the library are not handled correctly in example app. Regular functions and React components work without problems.
However, when I have this class in library
./src/index.ts
:And I run the example app, I get error:
Workaround
I was able to workaround by changing the
babel.config.js
in example app to this:I think typescript classes should work out of the box after default install of
create-react-native-library
.I think this can be accomplished by updating
react-native-builder-bob/babel-config.js
.Packages
Selected options
Link to repro
https://github.com/dirkpostma/react-native-library-with-class
Environment