Comments (5)
Sorry, I don't quite understand what you mean here. There is already documentation for adding a mock file to your project, is that not enough?
from react-native-svg-transformer.
I'm closing this as inactive, let's re-open if something new comes up.
from react-native-svg-transformer.
I ran into an error that I believe the original author was trying to convey. My project uses Typescript and Jest. Using the documentation provided on mocking this library doesn't work. However, using the author's suggestion the mock works.
from react-native-svg-transformer.
Just to contribute to anyone trying to use the .js setup in a TypeScript project, follow @davidsonsns's suggestion and everything will work.
I believe that could be helpful to add documentation to create a
svgMock
file for typescript project. Maybe people want to add just.ts
files in your folder structure.To fix on my current project I did it:
const exported = 'SvgMock'; export const ReactComponent = exported; export default exported;If sounds good I can contribute to the project with this adding it on the documentation.
from react-native-svg-transformer.
tbh i don't remember exactly the issue (pls lemme know if im overcomplicating things @jeandiego - btw mentioning you because you were the most recent person to comment).
but the issue is: if a project only include ts
files (or at least try to do so), most of the time maintainers will try to create __mocks__/svgMock.ts
(with .ts
) rather than __mocks__/svgMock.js
(with .js
).
so we could introduce something like below to the README:
// __mocks__/svgMock.js
module.exports = "SvgMock";
module.exports.ReactComponent = "SvgMock";
// TS version
// __mocks__/svgMock.ts
const exported = 'SvgMock';
export const ReactComponent = exported;
export default exported;
off-topic: damn! my english was really bad back in 2019 (It's still not perfect, but it's gotten a little better). my bad @kristerkari
from react-native-svg-transformer.
Related Issues (20)
- Identifier 'Svg' has already been declared HOT 6
- Import local svg without extension
- TypeError: Cannot read properties of undefined (reading 'has') HOT 2
- svg does not display properly when used with styled-components HOT 2
- Could we add support for optional import svg as a string not a `SvgComponent`? HOT 1
- Fails to find react-native-babel-transformer when used with React Native 0.73 because the package has been renamed HOT 4
- RN 0.73 compatibility HOT 1
- metro-react-native-babel-transformer needs to be replaced in RN 0.73 HOT 11
- Latest Expo SDK 50 beta adds new upstream transformer, causing bundle failure HOT 1
- EXPO RN Cannot display SVG, issue with RNSVGPath
- Expo SDK 50 crashes when apply metro config HOT 2
- Expo SDK 50 - cannot read properties of undefined (reading 'cacheable') HOT 2
- Unexpected import of expo metro config HOT 4
- missing-asset-registry-path HOT 1
- React native svg transformer does not color svg using replaceAttrValues HOT 4
- Expo 50 Solution
- Unable to resolve 'path' in @svgr/core HOT 2
- metro.config.js 配置多个 babelTransformerPath
- Solution to TypeError: Cannot read properties of undefined (reading '0') HOT 1
- Unable to resolve module HOT 4
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-svg-transformer.