这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Conversation

@harrisrobin
Copy link
Contributor

Expo broke due to a mistake in #330 . Turns out react-native-screens (I've tested 2.2.0 and 2.5.0) wasn't working with expo so I decided to use the JS stack if expo is used. Would you be able to take a look at this @bryanstearns ?

Thanks!

@harrisrobin harrisrobin marked this pull request as draft April 16, 2020 21:40
Copy link
Contributor

@bryanstearns bryanstearns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generated new expo and non-expo apps - both start correctly on simulators.

However, the Expo app's storybook test fails because of misconfiguration of asyncstorage, with a helpful message; it also doesn't `yarn lint` (because it has no `index.js`), nor `yarn compile` (several type errors, only one of which seems to be related to this change)
FAIL   iOS  test/storyshots.test.ts
  ● Test suite failed to run

    [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

    To fix this issue try these steps:

      • Run `react-native link @react-native-community/async-storage` in the project root.

      • Rebuild and restart the app.

      • Run the packager with `--reset-cache` flag.

      • If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app.

      • If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://github.com/react-native-community/async-storage/blob/LEGACY/docs/Jest-integration.md

    If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-async-storage/issues

      13 |   host: "localhost",
      14 |   onDeviceUI: true,
    > 15 |   asyncStorage: require("@react-native-community/async-storage"),
         |                 ^
      16 | })
      17 |
      18 | export const StorybookUIRoot: React.FunctionComponent = () => {

      at Object.<anonymous> (node_modules/@react-native-community/async-storage/lib/AsyncStorage.js:22:9)
      at Object.<anonymous> (node_modules/@react-native-community/async-storage/lib/index.js:5:1)
      at Object.<anonymous> (storybook/storybook.tsx:15:17)
      at Object.<anonymous> (storybook/index.ts:4:1)


const Stack = createNativeStackNavigator<RootParamList>()
<% if(props.useExpo){ %>
const Stack = createStackNavigator<RootParamList>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added your changes from this PR to a project I created last night. Everything seems to work, but I am getting a type error from line 16/24 below because stackPresentation doesn't exist on Stack.Navigator for @react-navigation/stack.

Copy link
Contributor

@bryanstearns bryanstearns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another picky comment, sorry.

import { createStackNavigator } from "@react-navigation/stack"
<% } else{ %>
import { createNativeStackNavigator } from "react-native-screens/native-stack"
<% } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm so picky about spacing, but we can't use Prettier on the template files:

  • These imports shouldn't be indented; picture the generated file without the template conditionals, and you'll see that the imports should line up on the left.
  • The if line needs more spacing: if (props.useExpo) {
  • The else line needs a space too: else {
  • If you add a - to the closing tag (eg <% blah -%>) the templater won't output the newline following the tag. Do this to all three template tags that form this conditional, and things should look right. (Generate a new Expo & non-Expo app to be sure!)
  • The conditional below and the ones in root-navigator.tsx.ejs need the same fixes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, thank you for catching these

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryanstearns Does the generated app get prettier-ed after generation? If so, would these things be fixed? (I'm not against fixing them here, just wondering.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier doesn't fix extra single blank lines, but might fix indentation

@harrisrobin harrisrobin marked this pull request as ready for review April 20, 2020 17:01
Copy link
Contributor

@bryanstearns bryanstearns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🎉 :shipit:

@jamonholmgren jamonholmgren merged commit 1397749 into infinitered:master Apr 22, 2020
infinitered-circleci pushed a commit that referenced this pull request Apr 22, 2020
## [5.0.2](v5.0.1...v5.0.2) (2020-04-22)

### Bug Fixes

* **expo:** Rolls back to react-native-screens JS version for Expo ([#332](#332) by [@harrisrobin](https://github.com/harrisrobin)) ([1397749](1397749))
* Resolve require cycle warnings ([#309](#309) by [@harrisrobin](https://github.com/harrisrobin)) ([9945f76](9945f76))
* **tests:** Used default in import community AsyncStorage ([#329](#329) by @KZhidovinov) ([ce91008](ce91008))
@infinitered-circleci
Copy link
Collaborator

🎉 This PR is included in version 5.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants