score:24
found the answer on this site here
step 1: install both jquery and bootstrap
npm install jquery bootstrap --save
step 2: import them in vendor.ts:
import 'jquery';
import 'bootstrap/dist/js/bootstrap';
step 3: go to wepback.common.js in config directory and add this inside plugin section:
plugins:[
.....
..... ,
new webpack.provideplugin({
jquery: 'jquery',
$: 'jquery',
jquery: 'jquery'
})
]
this will let bootstrap to find jquery
as mentioned here you can not depend on es6 respecting the order of your import
statements
score:0
for me it's work in this way
import 'bootstrap/dist/css/bootstrap.css'
require('jquery')
require('bootstrap')
my react version is 17.0.2
score:1
for some reason jquery needs to be defined in lowercase too
import jquery from 'jquery'
global.jquery = jquery
global.jquery = jquery // jquery lowercase was the solution
global.$ = jquery
let bootstrap = require('bootstrap')
import 'bootstrap/dist/css/bootstrap.css'
score:1
after import all style css file add the below code in your index.js file
window.jquery = window.$ = require('jquery/dist/jquery.min.js');
require('bootstrap/dist/js/bootstrap.min.js');
score:2
window.$ = window.jquery = require('jquery');
you can use gulp and webpack to minify your files
score:2
testing with this
import jquery from 'jquery'
window.jquery = jquery
require('bootstrap')
Source: stackoverflow.com
Related Query
- Using Jquery and Bootstrap with Es6 Import for React App
- How to import and export components using React + ES6 + webpack?
- CDN links for React packages and how to import it when using react using the scripts from CDN
- Using different API url for development and production with React and axios
- Using modular CSS with Bootstrap 4 and React
- How can I build a React app with Webpack and import an assets folder?
- Approach for different HTML structure with React and using the same components
- Project layout for single-page app built using Clojurescript and React
- I have this `div` on my home page and want it to move with me when I scroll, I am using react for the website btw
- Working example for Graph Toolkit using SharePoint spfx, React and Get component with template
- Apache structure and config for React app with self hosted headless CMS
- I am using socketio with react as the frontend and node with express js to make an app
- Error Username and Pool information required while using Cognito with react app
- Using an ES6 Map with React and MobX doesn't rerender on all changes
- Circular dependencies with node modules import using Browserify and React
- Problem with testing for error in React component using react-query and axios. Test with React Testing Library, Jest, msw
- Can I create a file with functions only and import it in an App when using React?
- configuring jest and enzyme for react app using create-react-app
- Getting Bad request for POST request using Axios and CORS in Django and react app
- How to create a div with arrow and divider for content such that they are aligned using react and css?
- TypeError in using React app with jquery plugins
- Unable to build ES6 version of my React App with webpack and babel-preset-env
- Using specific filename for React components and containers with Webpack
- Import random file, using react js, babel and es6
- How to use static js generated throught webpack for react app with es6
- I'm using React using typescript with useContext and useReducer in my app, but for some reason the click won't trigger the dispatch
- How to replace Login/SignUp with Log out using React and Bootstrap
- Using an ES6 React Lib I've created with Babel and Rollup on Gatsby site
- Where can I add Form Fields so that they can be sent in Request Payload for POST method, I am inside a React App and using Fetches
- React app using Laravel for API and user login. Question about retrieving currently logged in user from database
More Query from same tag
- structure of a Backbone and React single page app
- state (from useState) using old value on a callback
- Is it possible to call useCallback inside another callback
- Get logged user every time the component renders under React ContextAPI
- How to map this type of API data?
- Properly updating arrays in component state using React
- Pass data back to React useContext
- Warning: A component is changing an uncontrolled input to be controlled
- react component props does not have match
- How to render NotFound Component react-router-config
- Stuck at "Cannot read property 'props' of undefined"
- Pass a component as props
- Missing "key" prop for element in iterator and Prop spreading is forbidden
- Function passed to child is being interpreted as a string
- React-slick with css modules
- (Error) Passing data from one component to another using React-Redux mapStateToProps + Reducers
- React: How do I render nested JSON data?
- React functional component: TypeError: handleFlagChange is not a function
- How do I make this table sortable?
- How to mock async method in an interface with Jest?
- ReactJS state value not update correctly on input onChange
- How do I change the layout for smaller screens in material ui?
- React Component this.variable not rendering
- webpack build failed
- 404 image react router dom link with parameter
- How can I find elements using testing-library's findByText() when those elements are under a div with a higher z-index?
- setState error for onclick in react
- Uncaught TypeError: Cannot read property 'map' of undefined with React
- How can I install ReactJs
- Targeting specific Lottie animations on hover with lottie-web in React