Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSX integration #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rams23
Copy link

@rams23 rams23 commented Mar 23, 2020

As for #169 here is my implementation of React.createElement wrapper that integrates cavy at jsx level.

It adds a cavyCreateElemement function that is a replacement for React.createElement, auto wraps function component and add component refs into testHookStore.

The testHookStore must be set at startup in the index.test.js together with a cavyIdPropName that let you configure how cavy takes identifier from props.

It uses @wordpress/babel-plugin-import-jsx-pragma and @babel/plugin-transform-react-jsx to globally replace JSX transpilaton.

I'm experiencing some problem with the metro bundler so I have created a repo to show it react-native-custom-jsx. If you look at build/index.metro.js you can see that there are some

import { cavyCreateElement } from "cavy"

that should not be there, while somewhere else the code is transpiled correctly to

var _cavy = _$$_REQUIRE(_dependencyMap[1], "cavy");
 _cavy.cavyCreateElement(...)

The import cause rn to crash at startup.

I'm investigating, I don't know if someone in the cavy team with a better knowledge of babel/metro can help me.

Thank you for your great job, I'm waiting for your comments and ready to answer your questions.

I'll eventually update docs and types if the feature will be merged.

@jalada
Copy link
Contributor

jalada commented Aug 24, 2020

Hi @rams23! Just a quick update for you. We're keeping this around because we really like the idea, and someone might want to use it before it gets merged. But right now, we're not sure where this fits on the Cavy roadmap. We're currently working through other bugs and issues, and if we get time we'll come back to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants