Skip to content

Commit

Permalink
feat: switch to new jsx runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 2, 2024
1 parent ee3dd9c commit fe76d57
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';

<% if (project.view) { -%>
import { StyleSheet, View } from 'react-native';
import { <%- project.name -%>View } from '<%- project.slug -%>';
<% } else { -%>
<% if (project.arch !== 'new') { -%>
import { useState, useEffect } from 'react';
<% } -%>
import { StyleSheet, View, Text } from 'react-native';
import { multiply } from '<%- project.slug -%>';
<% } -%>
Expand All @@ -28,9 +29,9 @@ export default function App() {
}
<% } else { -%>
export default function App() {
const [result, setResult] = React.useState<number | undefined>();
const [result, setResult] = useState<number | undefined>();

React.useEffect(() => {
useEffect(() => {
multiply(3, 7).then(setResult);
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"prettier"
],
"rules": {
"react/react-in-jsx-scope": "off",
"prettier/prettier": [
"error",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"jsx": "react-jsx",
"lib": ["ESNext"],
"module": "ESNext",
"moduleResolution": "Bundler",
Expand Down
7 changes: 6 additions & 1 deletion packages/react-native-builder-bob/babel-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ module.exports = function (api, options, cwd) {
modules: cjs ? 'commonjs' : false,
},
],
require.resolve('@babel/preset-react'),
[
require.resolve('@babel/preset-react'),
{
runtime: 'automatic',
},
],
require.resolve('@babel/preset-typescript'),
require.resolve('@babel/preset-flow'),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-builder-bob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ yargs
allowUnusedLabels: false,
esModuleInterop: true,
forceConsistentCasingInFileNames: true,
jsx: 'react',
jsx: 'react-jsx',
lib: ['ESNext'],
module: 'ESNext',
moduleResolution: 'Bundler',
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"jsx": "react-jsx",
"lib": ["esnext", "dom"],
"module": "esnext",
"moduleResolution": "node",
Expand Down

0 comments on commit fe76d57

Please sign in to comment.