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

Convert SafeAreaView to ES Module #31330

Closed
lunaleaps opened this issue Apr 8, 2021 · 5 comments
Closed

Convert SafeAreaView to ES Module #31330

lunaleaps opened this issue Apr 8, 2021 · 5 comments
Assignees
Labels
Component: SafeAreaView Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.

Comments

@lunaleaps
Copy link
Contributor

lunaleaps commented Apr 8, 2021

Description

SafeAreaView is currently using CommonJS export, we'd like to update this to use ES modules. You can find more about the differences here: https://irian.to/blogs/what-are-cjs-amd-umd-and-esm-in-javascript/

Expected Results

A default exported SafeAreaView module and relevant updates from require to import (caveat: inline requires, which will should be updated to require(...).default.
You can use flow to catch any callsites missed.

Note

  • Please assign yourself if interested! I believe you might need to comment on the issue before you can assign yourself? Otherwise please let me know so I can assign to you!
@lunaleaps lunaleaps added Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Component: SafeAreaView Needs: Triage 🔍 labels Apr 8, 2021
@franzon
Copy link
Contributor

franzon commented Apr 11, 2021

Hey! I'm a brazilian student and interested in starting contributing to open source software. I use React Native every day, so I think that it would be a good project to start.

Can I start working on this issue?

@lunaleaps
Copy link
Contributor Author

Yes! Thank you for offering! Just assigned! Question: were you not able to assign yourself? (Just trying to understand if I should change my issue description)

@franzon
Copy link
Contributor

franzon commented Apr 12, 2021

Thank you! I was not able to assign myself.

facebook-github-bot pushed a commit that referenced this issue Apr 14, 2021
Summary:
Convert SafeAreaView to ES Module (#31330).

## Changelog

[General] [Changed] - Converted `SafeAreaView` to ES Module.

Pull Request resolved: #31344

Test Plan: Tested that `npm test` passes.

Reviewed By: kacieb

Differential Revision: D27767463

Pulled By: lunaleaps

fbshipit-source-id: fd3aee58ae6d621a292ff3360d8833f5e5007d52
Kudo pushed a commit to Kudo/react-native that referenced this issue Apr 16, 2021
Summary:
Convert SafeAreaView to ES Module (facebook#31330).

## Changelog

[General] [Changed] - Converted `SafeAreaView` to ES Module.

Pull Request resolved: facebook#31344

Test Plan: Tested that `npm test` passes.

Reviewed By: kacieb

Differential Revision: D27767463

Pulled By: lunaleaps

fbshipit-source-id: fd3aee58ae6d621a292ff3360d8833f5e5007d52
@kacieb kacieb linked a pull request Apr 23, 2021 that will close this issue
@kacieb
Copy link
Contributor

kacieb commented Apr 23, 2021

Looks like this is done, feel free to reopen if not!

@kacieb kacieb closed this as completed Apr 23, 2021
@johnpawl
Copy link

I want to get back to android activity from react-native activity using backkey .

MainActivity.java

public class MainActivity extends AppCompatActivity {

Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = (Button) findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startRNPage();
        }
    });
}

private void startRNPage() {
    Intent intent = new Intent(this, ReactNativeActivity.class);
    startActivity(intent);
    finish();
}
}

ReactNativeActivity.java

public class ReactNativeActivity extends AppCompatActivity {
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SoLoader.init(this, false);

    mReactRootView = new ReactRootView(this);
    List<ReactPackage> packages = new PackageList(getApplication()).getPackages();
    // Packages that cannot be autolinked yet can be added manually here, for example:
    // packages.add(new MyReactNativePackage());
    // Remember to include them in `settings.gradle` and `app/build.gradle` too.

    

    mReactInstanceManager = ReactInstanceManager.builder()
    .setApplication(getApplication())
    .setCurrentActivity(this)
    .setBundleAssetName("index.android.bundle")
    .setJSMainModulePath("index")
    .addPackages(packages)
    .setUseDeveloperSupport(BuildConfig.DEBUG)
    .setInitialLifecycleState(LifecycleState.RESUMED)
    .build();
    // The string here (e.g. "MyReactNativeApp") has to match
    // the string in AppRegistry.registerComponent() in index.js
    mReactRootView.startReactApplication(mReactInstanceManager, "firstpro", null);

    setContentView(mReactRootView);
    }
@Override
public void onBackPressed() {
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onBackPressed();
    } else {
      super.onBackPressed();
    }
}
}

I also tried the following code in ReactNativeActivity.java

public void onBackPressed() {
    if (mReactInstanceManager != null) {
        mReactInstanceManager.onBackPressed();
    } else {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }
}

If I pressed the back button it didn't get back to android activity.

How can I get back to android activity from react-native activity using backkey?

@facebook facebook locked as resolved and limited conversation to collaborators Apr 23, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: SafeAreaView Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants