Earlier my app was in ReactJs + React-bootstrap. Now I'm using Typescript + ReactJs + React-bootstrap
To reduce the size of the app for production Earlier I used to import react-bootstrap components using -
import Button from 'react-bootstrap/lib/Button'
After adding Typescript it shows the following error
ERROR in [at-loader] ./components/Hello.tsx:6:8 TS1192: Module ''react-bootstrap/lib/Button'' has no default export.
Trial 1
import {Button} from 'react-bootstrap/lib/Button' but in this case Button is undefined.
Trial 2
import * as Button from 'react-bootstrap/lib/Button' but in this case another error pops out
ERROR in [at-loader] ./components/Hello.tsx:54:12 TS2604: JSX element type 'Button' does not have any construct or call signatures.
This error shows error in line <Button onClick={handleClick} bsStyle="danger" bsClass="glyphicon glyphicon-new-window"></Button>
Though import {Button} from 'react-bootstrap' works fine but this is not desired because it results in increasing the size of the app by 200kbs for me.
How can we import specific component from react-bootstrap using Typescript??
import {Button} from 'react-bootstrap'as whole react-bootstrap gets imported but in {Button} the Button component gets imported. Its tried and tested that there is increase in sizereact-bootstrapis bundled, it is not possible for UglifyJS to only import everything necessary.requirecalls kill all possible optimization. If you want to keep your app size small the way @iamsaksham is doing it, is the correct way.{}are for. If you compare a similar approach is done with destructuring propsreact-bootstrapfor sure increases size butreact-bootstrap/lib/Buttonis quite cheap in size.imports theButton, but it will include the whole library in the bundle anyway :( This does not happen if you import fromlib.