Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between import { AppRegistry } from 'react-native'; and import AppRegistry from 'react-native';

sometimes we load something in es6 like:

import FlatList from 'react-native';

but sometimes we covered this imported object with curly brackets like

import {'FlatList'} from 'react-native';

please tell me when should use this brackets or not.

like image 806
Ahmed Sohel Avatar asked Apr 10 '26 05:04

Ahmed Sohel


1 Answers

This is the difference between a named export and a default export. Ref

If the module exports a module as a default (ex: export default FlatList;), it can be accessed by import FlatList from "react-native".

If it's a named export (ex: export const FlatList;), it will have to be imported as import {FlatList} from "react-native".

It's entirely up to the module authors to export it as they see fit. You should consult the documentation to know how to import it for sure.

like image 99
ncabral Avatar answered Apr 12 '26 18:04

ncabral



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!