Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated React Native example #4

Merged
merged 2 commits into from
Feb 7, 2022
Merged

Updated React Native example #4

merged 2 commits into from
Feb 7, 2022

Conversation

iujames
Copy link
Contributor

@iujames iujames commented Feb 7, 2022

There aren't really that many updates here, but I think the package-lock.json makes it look that way.

key updates:

  • fully implemented RN SDK wrappers for remaining functions: reset(), anonymous() and group(id, props)
  • build out an example app that mirrors the native samples - sign in page, then pages for events, profile, group - to exercise SDK functionality
  • updated bundled Android lib to include new startup logic André recently added

The example app contents is probably the most interesting thing here. The structure of that example is now:

example/
|-- ios/ --> generated xcodeproj stuff
|-- android/ --> generated android studio project stuff
|-- components/
|--|-- { three custom button styles - filled, plain, tinted }
|-- contexts/
|-- |--UserContext.js --> for passing User ID state through app
|-- screens/
|-- | main/
|-- |-- MainScreen.js --> root tabs
|-- |-- EventsScreen.js
|-- |-- ProfileScreen.js
|-- |-- GroupScreen.js
|-- | signin/
|-- |-- SignInScreen.js --> initial page for user ID input
|-- style/
|-- |-- AppcuesStyle.js --> theme, text, input shared styles
|-- App.js --> main entry point

rn_exmaple

@iujames iujames force-pushed the feature/react-example branch from ac364cd to 5e12c14 Compare February 7, 2022 17:04
Copy link
Contributor

@andretortolano andretortolano 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, I dont have much to say about the react implementation.

example/App.js Outdated
<RootStack.Screen name="Sign In" component={SignInScreen}
options={({ navigation }) => ({
headerShadowVisible: false,
headerTitleStyle: { fontWeight: 'bold' },
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI iOS navigation titles are semi bold if you want to match it exactly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah ok, looks like that is 600 in RN terms, no semibold out of box https://gist.github.com/knowbody/c5cdf26073b874eae86ba96e7cf3a540

Copy link
Contributor

Choose a reason for hiding this comment

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

Tangential, but I wonder if it's better if we use those values in the experience model for fontWeight instead of the named ones. The names ones might be pretty iOS-specific?

@andretortolano any preference?

@iujames iujames merged commit ea10bc9 into main Feb 7, 2022
@iujames iujames deleted the feature/react-example branch February 7, 2022 18:05
Copy link

@evandavis evandavis left a comment

Choose a reason for hiding this comment

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

I could add more comments about various lines and things, but I don't think it's all that important for this example to look like our in-house style 🤷

const [userID, setUserID] = useState('default-00000');

// Initialize the Appcues SDK as early as possible in your app
Appcues.setup('ACCOUNT_ID', 'APP_ID')

Choose a reason for hiding this comment

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

This should probably be inside a useEffect so that it only runs once; this component can re-render if setUserID is called.

useEffect(() => {
  Appcues.setup('ACCOUNT_ID', 'APP_ID');
}, []);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah got it, will do thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

turns out this does cause some additional complication, as the useEffect hook only runs after the first render, and there is some code during that render that attempts to access/use the SDK for a screen view during a useFocusEffect hook. Not sure what best practice there would be yet.

example/App.js Show resolved Hide resolved
example/components/FilledButton.js Show resolved Hide resolved
example/screens/main/ProfileScreen.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants