Unable to render Reactjs-boostrap popover - react-bootstrap

I have the following package installed:
npm install --save react-bootstrap bootstrap
And I am trying to add a popover using an example provided here example.
This is the exact code:
import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import Popover from 'react-bootstrap/Popover';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Button from 'react-bootstrap/Button';
function App() {
const popover = (
<Popover id="popover-basic">
<Popover.Title as="h3">Popover title</Popover.Title>
<Popover.Content>
Popover content <strong>some strong content</strong> Normal content again
</Popover.Content>
</Popover>
);
return (
<div className="App">
<OverlayTrigger trigger="click" placement="right" overlay={popover}>
<Button variant="success">Click to trigger popover</Button>
</OverlayTrigger>
</div>
);
}
export default App;
But it just doesn't work. I don't see any errors in the console. And the popover does not render at all. What am I missing?

Probably you just need npm install react-bootstrap bootstrap. That is mentioned on the doc you suggested too.
From this Article,
Before npm 5.0.0, it was necessary to add --save after package name because it
will save the installed package to package.json file in the dependency section.
If you are using a recent version of npm save yourself from unnecessary typing
and use npm install [Package Name] instead of npm install [Package Name] --save
by default it will add the installed package to the dependency list in the
package.json file.

Related

Sudden VueJS error: ERROR in multi vue, module not found: Error: Can't resolve 'vue' in

Every day, I come to my office, launch my IDE (Code - OSS) and run npm run watch. Every day it works like a charm. But not today. Oddly enough, today running npm run watch fires this error:
ERROR in multi vue
Module not found: Error: Can't resolve 'vue' in
'/home/TopSecretUser/Code/Local/TopSecretProject/11.11.2020/dev'
# multi vue /js/vendor[0]
ERROR in ./resources/js/app.js
Module not found: Error: Can't resolve 'vue' in
'/home/me/Code/Local/TopSecretProject/11.11.2020/dev/resources/js'
# ./resources/js/app.js 3:13-16 4:0-22 6:0-3 85:14-17
# multi ./resources/js/app.js ./resources/css/app.css
My app.js starts with the following lines:
require("./bootstrap");
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
...
I haven't made any changes from yesterday to today, so I am totally confused. I tried some fixings but nothing worked. Does anyone have any suggestion how i can fix this? I am using vue#2.6.11.
You could delete the node_modules which could be affected by an external action like deletion/moving or you mis-installed a module, then rerun :
npm install
this will fetch the dependencies in package.json and install them, you should always install a module by adding --save or --save-dev flag with npm i like npm i some-module --save
guys I had this issue, after a while I found the solution , just import component as this:
Vue.component('Date',required('components/Date.vue'));
it's my pleasure to follow me on instagram: https://www.instagram.com/mahdiabedi220/

Cant add external js library in laravel project

I want to use bs treeview.js library in my laravel project and i don't know how to do it. So far I have done the following:
npm install --save bstreeview
I added require ('bstreeview'); in resources/js/app.js
When I try to compile it with npm run dev I get the
ERROR in ./resources/js/app.js Module not found: Error: Can't resolve
'./bstreeview' in (...)
What am I doing wrong?
i have check this package there is not index.js
so you can't import directly you can include file like this
import 'bstreeview/dist/js/bstreeview.min.js';
require ('bstreeview'); it's means node is looking for index.js insde
node_module/bstreeview/index.js but in this package it is not there so u need to manually import like above mentioned
for
jquery
run npm i jquery
and inside bootstrap.js add this
window.$ = window.jQuery = require('jquery');

Installing MDB Vue in Laravel 5.8

I want to install MDB Vue in my fresh Laravel application Im trying to do it via npm but it's not working
I did :
1- created fresh Laravel app
2- Go to the directory www/myApp
3- npm install
4- npm install --save mdbvue
5- npm install --save-dev babel-preset-stage-2
6- I open app.scss
and add:
// Material Design Bootstrap
#import url('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
#import '~bootstrap/scss/bootstrap';
#import "~mdbvue/build/css/mdb.css";
7- I open ressources/js/bootstrap.js
I add:
try {
window.Popper = require('popper.js').default;
window.$ = window.jQuery = require('jquery');
require('bootstrap');
require('mdbvue'); // I added this!
} catch (e) {}
it require('mdbvue') I notice a message in the picture:
https://i.imgur.com/IkKvXkb.jpg
I can't post it need more reputations
I keep going I did
8- npm run dev
Everything is green and looking fine but when
I go take MDB buttons in exemple and put themes in my view it's not working
did I missed something ? help please
Your have to add your imports in the app.js file.
import 'bootstrap-css-only/css/bootstrap.min.css';
import 'mdbvue/build/css/mdb.css'
For me it works without the require('mdbvue'); in the bootstrap.js.
But i think the reason you did´nt get an answer for your question is, there are other problems with the integration of mdbvue into the laravel environment.
For example i have not found a way yet to import fontawesome from my npm-installation folder import '#fortawesome/fontawesome-free/css/all.min.css';.
But when i add <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"> to my html-head, fontawesome works.
If i find some solutions, i will update this post.
Hope i could help you a bit.
I had the same issue, I could solved it like this:
Cd into your project
Run: npm install
Run: npm install mdbvue
Add the following code to your 'resources/js/app.js' file:
require('./bootstrap');
import '#fortawesome/fontawesome-free/css/all.min.css'
import 'bootstrap-css-only/css/bootstrap.min.css'
import 'mdbvue/lib/css/mdb.min.css'
Add the following code to your 'resources/js/bootstrap.js' file:
require('mdbvue');
Run: npm run dev
It worked for me, using laravel 5.8.35 and the lastest version of MDVUE.

Ckeditor5 is not found after installing it throug npm and compiling throug laravel mix

I have installed ckeditor5 using npm in my laravel 5.6 project ( npm install --save #ckeditor/ckeditor5-build-classic) then i added window.ckeditor = require('#ckeditor/ckeditor5-build-classic');
to my resources/assets/js/app.js and ran npm run dev.The compilation was successfull.
In my view when i try to reference ckeditor, it says it cannot find ckeditor. please help
here is my resources/assets/js/app.js
require('./bootstrap');
window.Vue = require('vue');
/* tried both of these options one by one*/
window.ckeditor = require('#ckeditor/ckeditor5-build-classic');
// import ClassicEditor from "#ckeditor/ckeditor5-build-classic";
Try import ClassicEditor from "#ckeditor/ckeditor5-build-classic";
Installing Instructions
Try using the following:
const ClassicEditor = require( '#ckeditor/ckeditor5-build-classic' );

Ionicons not showing after npm installation

I installed ionicons using npm install --save ionicons so that my package.json updated to:
"dependencies": {
"ionicons": "^3.0.0"
}
Next, I added the following in my /resources/assets/sass/app.scss:
// Ionicons
#import "node_modules/ionicons/dist/scss/ionicons";
After successfully running npm run dev, I ended up with
/public
/css
app.css
/fonts
/vendor
/ionicons
/dist
ionicons.eot
ionicons.svg
ionicons.ttf
ionicons.woff
ionicons.woff2
With no errors in the browser console, not a single ionicon (e.g. <i class="icon ion-home"></i>) is showing. I inspected public/css/app.css, and found that it references ionic fonts like so: /fonts/vendor/ionicons/dist/ionicons, which seems to comply with the folder structure above.
I tried adjusting #import, changing url(...) refrences in app.css, moving fonts directory - no luck. Lastly, I tried to reference ionicons through a CDN, and it worked like charm.
What am I doing wrong here? Thanks
It turns out that I was using the docs for the wrong version of ionicons:
v2.0.0 ionicons.com
v3.0.0 ionicframework.com/docs/ionicons
If you install ionicons with NPM as I did, you'll get the latest version; if you clone them from their github repository, you'll get v2.0.0. It turns out that in v3.0.0, many icon classes were removed/changed, hence I couldn't see <i class="icon ion-home"></i>, what a waste of time!
Paste these two lines right before your tag:
<script type="module" src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/ionicons#5.5.2/dist/ionicons/ionicons.js"></script>
Uninstall ionicon from your depencency:
npm uninstall ionicons
For anyone else facing this issue. This is what fixed it for me :slight_smile:
npm uninstall ionicons
npm install ionicons
when you install the package
add this command : ng add #ionic/angular
Now the Ionicons has been updated to v4.x. (Answer written at 2019-06-24)
Try like this:
Before import the scss after install, set the value of $ionicons-font-path:
$ionicons-font-path: "~ionicons/dist/fonts";
#import '~ionicons/dist/scss/ionicons.scss';
When use the icon tag, write in ion-icon tag:
<ion-icon name="add"></ion-icon>

Resources