Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Tutorial - Instalação do Drawer Navigation

No projeto, instalar as seguintes dependências:


npm install @react-navigation/native react-native-screens react-native-safe-area-context
@react-navigation/drawer react-native-gesture-handler@2.1.1 react-native-reanimated
No MainActivity, adicionar:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
}

e no topo do MainActivity;
import android.os.Bundle;

No App.js, acrescentar ao topo:


import 'react-native-gesture-handler';

Em babel.config.js, acrescentar:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};

Em android/app/build.gradle, ativar o Hermes:


project.ext.react = [
enableHermes: true // <- here | clean and rebuild if changing
]

Em MainApplication.java, acrescentar:
import com.facebook.react.bridge.JSIModulePackage; // <- add
import com.swmansion.reanimated.ReanimatedJSIModulePackage; // <- add
...
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
...

@Override
protected String getJSMainModuleName() {
return "index";
}

@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage(); // <- add
}
};

Após todos esses passos, resetar o server com:


npx react-native start --reset-cache

E após:
npm run android

You might also like