Comments (4)
Well I didn't find any elegant solution to load the assets directly from the Platform.web.tsx
file...
🤷🏼♂️ I don't know how to use the Module ID that Metro provides on the Web and get to the asset...
👀 I'm open to suggestions if anyone has any?
In the meantime, I plan to update the documentation with 2 possible approaches:
- for publicly accessible folders (
public/
andassets/
), you can adapt the loading based on the platform:
// ONLY FOR PUBLIC FOLDER: Ternary based on platform
const myAssetPath = 'assets/images/my-image.png';
const relativePathToTheAssetFolder = '../../';
const asset = (Platform.OS === 'web') ? `/${myAssetPath}` : require(`${relativePathToTheAssetFolder}${myAssetPath}`);
- if you want to load assets outside of those folders, you can use
expo-asset
:
import { useAssets } from 'expo-asset';
// (...)
const [assets, error] = useAssets([require(`../random-folder/my-image.png`)]);
const asset = (!error && assets) ? assets[0].uri : null;
from react-native-skia.
The main issue comes with the fact that react-native Image.resolveAssetSource()
util is not available on the Web 🥹
from react-native-skia.
As per @william-candillon's comment, closing this issue per #2176 fix
from react-native-skia.
👉 Shouldn't be implemented in Platform.web.tsx
but rather better documented (how to load assets on RN web), so that RN Skia could run on the web without any RN dependency.
from react-native-skia.
Related Issues (20)
- SkBitmap HOT 23
- Value is undefined, expecting an object HOT 2
- Support Hue Saturation Lightness `hsl()` & `hsla()` HOT 1
- Opacity is not working on Paragraph HOT 2
- Skia.ParagraphBuilder is undefined HOT 2
- hello-snack from tutorial is not working HOT 2
- Matrix4 is not working for skia elements
- Dev works but main/prod environment broken/have different behaviors on android HOT 1
- App Crashes When Scrolling with FlatList HOT 1
- Create driving animations HOT 3
- Dashed line HOT 1
- Height and width constant of a canvas
- Path dash return SkPath HOT 3
- Cannot read properties of undefined (reading 'Path') TypeError: Cannot read properties of undefined (reading 'Path') HOT 7
- Canvas onTouch Android HOT 3
- "Hello world" example code in Atlas document runs blank View, whereas "Animations" functions properly. HOT 1
- The useTexture function throws an error on Android: "Cannot read property 'getCanvas' of null" . HOT 6
- The Atlas API's transform exhibits random anomalies. HOT 3
- property opacity not working in some Element. include: <Group/>; <Picture/> HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-skia.