I have existing iOS swift application. I integrate it to react-native. But when i added "import {Canvas,Circle, Image, Path} from 'react-fabricjs';" i have error
enter image description here
my package.json
{
"name": "uploader",
"version": "1.0.0",
"private": true,
"description": "Uploader",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react": "~15.3.0",
"react-dom": "~15.3.0",
"react-fabricjs": "^0.1.6",
"react-native": "~0.34.0",
"jsdom": "~9.9.1"
}
}
my index.ios.js
'use strict';
// 1
import React from 'react';
import {Canvas,Circle, Image, Path } from 'react-fabricjs';
import ReactNative, {
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native';
// 2
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'yellow',
},
welcome: {
fontSize: 35,
color: 'green',
},
});
// 3
class AddRatingApp extends React.Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>See you later alligator !</Text>
</View>
)
}
}
// 4
AppRegistry.registerComponent('AddRatingApp', () => AddRatingApp);
How I can import any React library into react-native application?
Any libraries that uses html/css/DOM will not work with React Native. This one is a html5 library that will work with React, but not React Native.
Related
hye,
since yesterday I try to deploy my application on cyclicapp but it gives me this error:
Could not resolve '../../vendor/tightenco/ziggy/dist/vue.m' from resources/js/app.js
error during build:
package.json:
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "npm start"
},
"devDependencies": {
"#inertiajs/inertia": "^0.11.0",
"#inertiajs/inertia-vue3": "^0.6.0",
"#inertiajs/progress": "^0.2.7",
"#tailwindcss/forms": "^0.5.2",
"#tailwindcss/typography": "^0.5.2",
"#vitejs/plugin-vue": "^3.0.0",
"autoprefixer": "^10.4.7",
"axios": "^0.27",
"laravel-vite-plugin": "^0.6.0",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"sass": "^1.55.0",
"tailwindcss": "^3.1.0",
"vite": "^3.0.0",
"vue": "^3.2.31"
},
"dependencies": {
"#vitejs/plugin-vue": "^3.1.0",
"vue": "^3.2.36",
"vue-loader": "^17.0.0"
}
}
vite.config.js :
import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "#vitejs/plugin-vue";
export default defineConfig({
plugins: [
laravel({
input: "resources/js/app.js",
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
});
app.js:
import "./bootstrap";
import "../css/app.css";
import { createApp, h } from "vue";
import { createInertiaApp } from "#inertiajs/inertia-vue3";
import { InertiaProgress } from "#inertiajs/progress";
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
import { ZiggyVue } from "../../vendor/tightenco/ziggy/dist/vue.m";
const appName =
window.document.getElementsByTagName("title")[0]?.innerText || "Laravel";
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue")
),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
.mount(el);
},
});
InertiaProgress.init({ color: "#4B5563" });
myproject is a laravel9 + inertia js + vue3 + jetstream
any help please
I integrated Material UI into my Svelte project with help of "Svelte Material UI" package.
But it don't contains Material layout-grid component.
I installed it separately using yarn add "#material/layout-grid" command.
But now I'm getting error during build process:
[!] (plugin postcss) Error: Invalid CSS after "...ch $size in map": expected expression (e.g. 1px, bold), was ".keys(variables.$co"
node_modules/#material/layout-grid/mdc-layout-grid.scss
Error: Invalid CSS after "...ch $size in map": expected expression (e.g. 1px, bold), was ".keys(variables.$co"
at options.error (/media/hdd-home/d/WebServers/home/spadmin.org/public_html/todoapp/node_modules/node-sass/lib/index.js:291:26)
So, I gave up resolving it myself.
The project package.json:
{
"name": "svelte-app",
"version": "1.0.0",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv ."
},
"devDependencies": {
"#mdi/js": "^5.3.45",
"#rollup/plugin-commonjs": "^12.0.0",
"#rollup/plugin-node-resolve": "^8.0.0",
"#smui/button": "^1.0.0-beta.21",
"#smui/card": "^1.0.0-beta.21",
"#smui/checkbox": "^1.0.0-beta.21",
"#smui/chips": "^1.0.0-beta.21",
"#smui/common": "^1.0.0-beta.21",
"#smui/form-field": "^1.0.0-beta.21",
"#smui/linear-progress": "^1.0.0-beta.21",
"#smui/textfield": "^1.0.0-beta.21",
"#smui/top-app-bar": "^1.0.0-beta.21",
"material": "^0.4.3",
"node-sass": "^4.14.1",
"rollup": "^2.3.4",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-postcss": "^3.1.1",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"svelte": "^3.0.0",
"svelte-preprocess": "^3.7.4"
},
"dependencies": {
"#material/layout-grid": "^6.0.0",
"sirv-cli": "^0.4.4"
}
}
And here is rollup.config.js
import svelte from 'rollup-plugin-svelte';
import resolve from '#rollup/plugin-node-resolve';
import commonjs from '#rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import livereload from 'rollup-plugin-livereload';
import {terser} from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import autoPreprocess from 'svelte-preprocess';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'scripts/app.js',
},
plugins: [
copy({
targets: [
{src: 'src/index.html', dest: '.'},
],
}),
svelte({
dev: !production,
emitCss: true,
css: css => {
css.write('css/app.css');
},
preprocess: autoPreprocess()
}),
resolve({
browser: true,
dedupe: ['svelte', '#material'],
}),
commonjs(),
postcss({
extract: 'css/app.css',
minimize: true,
sourceMap: true,
use: [
[
'sass', {
includePaths: [
'./theme',
'./node_modules',
],
},
],
],
}),
!production && serve(),
!production && livereload({watch: ['scripts', 'css', 'src', 'theme']}),
production && terser(),
],
watch: {
clearScreen: false,
},
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
});
}
},
};
}
It clearly tries to parse the scss file as css. So it probably misses the compile step. I can't find the scss rollup plugin in your package.json.
Check this, it could solve your problem: https://www.npmjs.com/package/rollup-plugin-scss
is there a way to import svg icons dynamicly based on a json file using Material-ui Svg icons?
Here's an example of my json file:
[
{
"name": "home",
"icon": "Home",
"title": "Home"
},
{
"name": "business",
"icon": "Business",
"title": "Business"
},
{
"name": "apartment",
"icon": "Apartment",
"title": "Apartment"
}
]
I want to map this json to create a menu list with icons
For those who need the same I've created a custom Icon component with a list of icons
import ApartmentIcon from '/path/to/icon';
import BusinessIcon from '/path/to/icon';
import HomeIcon from '/path/to/icon';
const IconList = {
apartment: ApartmentIcon,
business: BusinessIcon,
home: HomeIcon,
}
const Icon = ({ icon, ...props }) => {
const Component = Icons[icon];
return <Component {...props} />;
};
export default Icon;
So I can import the Icon component and then map the json to get the icon
menuJson.map((menuItem) => <Icon icon={menuItem.name} />)
Feel free to reach out if you need help with another implementation
// sample to your json:
const dynamicIcon: { [key: number]: React.ReactElement<SvgIconProps> } = {
home: <Home />,
business: <Business />,
apartment: <Apartment />,
};
// code usage:
<Box>
{ dynamicIcon['home'] }
</Box>
Spent lots of time on this issue but I can't find a different reason.
When using yarn (v1) with Plug and Play or yarn v2. (berry) I can't get
Material-UI theming v 4.4.3 working.
Here's the example below. There is no problem when using a standard non pnp yarn configuration.
(create-react-app)
import React from "react";
import logo from "./logo.svg";
import "./App.css";
import { createMuiTheme } from "#material-ui/core/styles";
import { ThemeProvider } from "#material-ui/styles";
import Button from "#material-ui/core/Button";
const theme = createMuiTheme({
props: {
MuiButton: { variant: "outlined" }
}
});
function App() {
return (
<ThemeProvider theme={theme}>
<div>
<Button>text</Button>
</div>
</ThemeProvider>
);
}
export default App;
my package.json
{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.4.3",
"#material-ui/styles": "^4.4.3",
"#material-ui/system": "^4.4.3",
"react": "^16.10.1",
"react-dom": "^16.10.1",
"react-scripts": "3.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
The theme is ignored.
Looks like it's a double initiation of #material-ui/styles problem. Guys from #material-ui team seem to be fixing this at the moment.
importing MuiThemeProvider as ThemeProvider from #material-ui/core/styles instead of importing ThemeProvider from #material-ui/styles fixed the issue.
I also ommited #material-ui/styles in my package.json
Hope this helps someone ...
I'm using React Native WebView to show html content from a file. I tested using iOS Simulator, it's working fine. But somehow when I test it on Android Emulator, the arabic text is not showing properly, instead of weird characters like: ä, ö, ü are appearing.
This is my code:
render() {
const { content } = this.state
return (
<View style={style.container}>
...
<WebView
source={{ html: content }}
onMessage={(event) => this.playAudio.call(this, event.nativeEvent.data)}
/>
</View>
)
}
componentDidMount() {
const { state } = this.props.navigation
RNFS.readFileAssets(`content/${state.params.item.id}`, 'utf8')
.then((content) => {
console.log('content', content)
this.setState({ ...this.state, content })
})
.catch((err) => {
console.log('error', err.message, err.code)
})
}
My package.json:
{
"name": "doadzikirandroid",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"moment": "^2.20.1",
"react": "16.0.0",
"react-native": "0.51.0",
"react-native-admob": "^2.0.0-beta.4",
"react-native-fs": "^2.9.6",
"react-native-gesture-handler": "^1.0.0-alpha.35",
"react-native-search-box": "^0.0.13",
"react-native-sound": "^0.10.4",
"react-native-tab-view": "^0.0.73",
"react-native-vector-icons": "^4.4.3",
"react-navigation": "^1.0.0-beta.22"
},
"devDependencies": {
"babel-jest": "22.0.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.0.4",
"react-test-renderer": "16.0.0"
},
"jest": {
"preset": "react-native"
}
}
Output:
Browser console log:
How should I do to fix this? Thanks in advance.
Here's the solution that worked for me. Add baseUrl: '' to source property of the WebView. UTF-8 displays correctly then!
<WebView
source={{baseUrl: '', html: "Your HTML content here"}}
style={}
bounces={true}
/>
source={{baseUrl: '', html: "..."}}
fixed it for me