Can't apply bootstrap to react (type is invalid) - react-bootstrap

I can't apply Bootstrap to my project.
import {Button, Form, Label, Input, Modal, ModalBody} from 'react-
bootstrap';
In my index.html I have a link to CDN.
I am confused because import worked in very similar project but with another imported components.
My render method
render() {
return (
<div>
...
<Modal name='modal' isOpen={this.state.showModal}>
<ModalBody>
Please add a popup for a location.
<Form name="form">
<Label for="Popup">Popup</Label>
<Input type="text" name="popup" id="popup" placeholder="Popup"/>
<Button bsStyle="primary" type="submit"
onClick={(e)=>this.submit(e)}>Add</Button>
</Form>
</ModalBody></Modal>
</div>
)
}
}
My imports to MapComponent component
import React, {Component} from 'react';
import {Button, Form, Label, Input, Modal, ModalBody} from 'react-
bootstrap';
import { Map, TileLayer, Marker, Popup } from 'react-leaflet'
My imports to the App component
import 'babel-polyfill';
import ReactDOM from 'react-dom';
import React from 'react';
import { Router, Route, hashHistory } from 'react-router';
import MapComponent from './MapComponent.jsx';
import styles from '../../css/styles.css';
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of MapComponent.
in MapComponent (created by RouterContext)
in RouterContext (created by Router)
in Router (created by App)
in App

Using CDN link you cannot import modules like,
import {Button, Form, Label, Input, Modal, ModalBody} from 'react-
bootstrap';
You need to install react-bootstrap.
npm install react-bootstrap --save
or
yarn add react-bootstrap
Update
You are importing {Button, Form, Label, Input, Modal, ModalBody} from react-bootstrap but you are using reactstrap code for your modal,
import {Button, Form, Label, Input, Modal, ModalBody} from 'react-bootstrap';
This is code for reactstrap modal
<Modal name='modal' isOpen={this.state.showModal}>
<ModalBody>
Please add a popup for a location.
<Form name="form">
<Label for="Popup">Popup</Label>
<Input type="text" name="popup" id="popup" placeholder="Popup"/>
<Button bsStyle="primary" type="submit"
onClick={(e)=>this.submit(e)}>Add</Button>
</Form>
</ModalBody></Modal>
You can change your import to make your code work
import {Button, Form, Label, Input, Modal, ModalBody} from 'reactstrap';
OR
If you want to use react-bootstrap modal then this is the code for modal
<Modal.Dialog>
<Modal.Header closeButton>
<Modal.Title>Modal title</Modal.Title>
</Modal.Header>
<Modal.Body>
<p>Modal body text goes here.</p>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary">Close</Button>
<Button variant="primary">Save changes</Button>
</Modal.Footer>
</Modal.Dialog>

Related

Laravel 9 vue js 3 Ckeditor 5 not showing

I want to install ckeditor to add blog posts to my Laravel 9 mix and vue js 3 project. If I do as the ckeditor says on his page, the ckeditor will not appear unless he makes a mistake
enter image description here
App.js
require('./bootstrap');
import { createApp } from "vue";
import App from './components/App';
import router from './router'
import store from "./store/store";
import AOS from 'aos'
import 'aos/dist/aos.css'
import CKEditor from '#ckeditor/ckeditor5-vue';
const app = createApp({});
app.AOS = new AOS.init();
app.component('my-app',App);
app.use(router)
app.use(store);
AOS.init();
app.mount('#wrapper');
createApp( { /* options */ } ).use( CKEditor ).mount( /* DOM element */ );
newBlog.vue file
<script setup>
import {mapGetters} from "vuex";
</script>
<template>
<div id="app">
<form #submit.prevent>
<div class="form-row mb-4">
<label>Blog adi</label>
<div class="form-group col-md-12">
<input class="form-control w-100" v-model="blogName">
</div>
</div>
<div class="form-row mb-4">
<label>Blog yazısı</label>
<div>
<ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
</div>
</div>
<button type="button" #click="send()" class="btn btn-primary mt-3">Redaktə et</button>
</form>
</div>
</template>
<script>
import ClassicEditor from '#ckeditor/ckeditor5-editor-classic/src/classiceditor';
import EssentialsPlugin from '#ckeditor/ckeditor5-essentials/src/essentials';
import BoldPlugin from '#ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '#ckeditor/ckeditor5-basic-styles/src/italic';
import LinkPlugin from '#ckeditor/ckeditor5-link/src/link';
import ParagraphPlugin from '#ckeditor/ckeditor5-paragraph/src/paragraph';
export default {
name: 'app',
data() {
return {
blogName: '',
editor: ClassicEditor,
editorData: '<p>Content of the editor.</p>',
editorConfig: {
// The configuration of the editor.
}
};
}
}
</script>
Export
enter image description here

Module not found: Can't resolve 'swiper/css/components/navigation/navigation.scss' Nextjs

I am new in Nextjs I am using the swiper in my component but I am getting an error and pagination navigation and swiper CSS is not found this code working fine in Reactjs when I use this code in Nextjs I am getting an error how to import this CSS in Nextjs
enter
import React, { useState } from "react";
import LandingItem from "../landing-item/landing-items-component";
import styles from "./landing-items-preview-styles.module.scss";
import SwiperCore, { Navigation } from "swiper";
import { Swiper, SwiperSlide } from "swiper/react";
import "swiper/css/components/navigation/navigation.scss";
import "swiper/css/components/pagination/pagination.scss";
import "swiper/css/swiper.css";
function LandingItemsPreview({ otherProps: { id, items, name } }) {
return (
<div className={`${styles.landing_items_preview}`}>
<div className={`${styles.header}`}>
<h1 className={`${styles.title}`}>{`Top ${name}`}</h1>
<button className={`${styles.view_all}`}>View All</button>
</div>
<div className={`${styles.swiper_main_container}`}>
<span
disabled={isBeginning}
className={`${styles.custom_swiper_button} ${styles.skewed}`}
onClick={goback}
>
➜
</span>
<Swiper>
{items.map(({ id, ...otherProps }) => (
<SwiperSlide key={id} className={`${styles.TopRestaurant_slides}`}>
<LandingItem {...otherProps} />
</SwiperSlide>
))}
</Swiper>
<span
disabled={isEnd}
className={`${styles.custom_swiper_button}`}
onClick={goNext}
>
➜
</span>
</div>
</div>
);
}
export default LandingItemsPreview;
here
They are available in compiled format, try this:
import 'swiper/components/navigation/navigation.min.css';
Try importing "navigation.min.css" instead "navigation.scss"

Nativescript Vue: How to access/manipulate view properties from other components?

I have a main App.vue with sub components inside. I am trying to get the scrolling from within my MovieScreenComponent to trigger another action in HeaderComponent. Is this possible? Otherwise, I'd have to have everything in the same component. This is code setup I have right now.
App.vue
<template>
<GridLayout>
<HeaderComponent />
<MovieScreenComponent />
</GridLayout
</template>
<script>
import HeaderComponent from './components';
import MovieScreenComponent from './components';
</script>
MovieScreenComponent.vue
<template>
<GridLayout>
<ScrollView scroll="onScroll"/>
</GridLayout
</template>
<script>
export default {
methods: {
onScroll: function() {
** How can I change something from within the HeaderComponent, such as image opacity, when I am within another component like this **
}
}
}
</script>

Shopify polaris (React js) button click event is not working

I am newbie to react js.
After couple of hours finally I have some login box code rendering.
But the issue is I am unable to bind click event on button.
What i am using.
Laravel 5.6
react js (16.3.1)
What i have tried until now is
https://www.tutorialspoint.com/reactjs/reactjs_events.htm
https://reactjs.org/docs/handling-events.html
This is my final code
import React, {Component} from 'react';
import {Page, Card, Button,List,TextField} from '#shopify/polaris';
export default class Login extends React.Component {
constructor() {
super();
this.loginBtbClicked = this.loginBtbClicked.bind(this);
}
loginBtbClicked() {
debugger;
console.log('Hello');
}
render() {
debugger;
/* Some css code has been removed for brevity */
var divStyle = {
width: '500px'
};
return (
<div className="mt-5 mx-auto" style={ divStyle }>
<Card title="Login" subdued sectioned>
<div>
<TextField label="Store Url" type="text" helpText='ex. store.myshopify.com'></TextField>
</div>
<div className="mt-5">
<Button size="large" fullWidth primary onClick = {this.loginBtbClicked} >Login</Button>
</div>
</Card>
</div>
);
}
}
Also help me with best practice in react js for form submit and click event.
Here is the link for github project
https://github.com/little-isaac/shopify-polaris-laravel-test.git
I have changed webpack.mix.js file's path
From
mix.react('resources/assets/js/app.js', 'public/app.js')
to
mix.react('resources/assets/js/app.js', 'js/app.js')
And forget to change public path
mix.setPublicPath('');

React-bootstrap code not rendering

I have installed react-bootstrap with npm (npm install react-bootstrap --save) but my code is not rendering on the browser. The page is just blank. I use webpack for builds and babel for transpilation. Below is my react code.
import React from 'react'
import ReactDOM from 'react-dom'
import ReactBootstrap from 'react-bootstrap'
const buttonsInstance = (
<ButtonToolbar>
<Button bsStyle="primary" bsSize="large" active>Primary button</Button>
<Button bsSize="large" active>Button</Button>
</ButtonToolbar>
);
ReactDOM.render(buttonsInstance, document.getElementById('root'));
Thanks!
Import the controls you'll use explicitly:
import React from 'react'
import ReactDOM from 'react-dom'
import {ButtonToolbar, Button} from 'react-bootstrap' // define individual controls to import
const buttonsInstance = (
<ButtonToolbar>
<Button bsStyle="primary" bsSize="large" active>Primary button</Button>
<Button bsSize="large" active>Button</Button>
</ButtonToolbar>
);
ReactDOM.render(buttonsInstance, document.getElementById('root'));

Resources