Code Monkey home page Code Monkey logo

Comments (7)

bvic23 avatar bvic23 commented on July 17, 2024

Could you attach your package.json, .babelrc and the functional component you'd like to use in storyboard? Could you also verify that HMR is enabled in the simulators/emulator?

from babel-plugin-functional-hmr.

MrLoh avatar MrLoh commented on July 17, 2024

Hi thanks a lot for the help. So everything is pretty standard:

package.json

{
   ...
  "dependencies": {
    ...
    "react": "16.0.0-alpha.12",
    "react-native": "0.47.2",
    "styled-components": "^2.1.1"
  },
  "devDependencies": {
    "@storybook/addon-actions": "^3.2.11",
    "@storybook/addon-links": "^3.2.10",
    "@storybook/react-native": "^3.2.11",
    "babel-eslint": "^7.2.3",
    "babel-plugin-functional-hmr": "^1.0.21",
    "babel-plugin-transform-react-jsx-source": "^6.22.0",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "lint-staged": "^4.0.3",
    "react-dom": "16.0.0-alpha.12",
    "react-native-dotenv": "^0.1.0",
    "react-native-scripts": "^1.1.0",
    "react-test-renderer": "16.0.0-alpha.12",
    ...
  },
  "rnpm": {
    "assets": [
      "./cinuru-design/assets/fonts/"
    ]
  },
  "lint-staged": {
    "*.js": [
      "prettier --write",
      "git add"
    ]
  }
}

.babelrc

{
  "presets": ["babel-preset-react-native-stage-0/decorator-support", "react-native-dotenv"],
  "env": {
    "development": {
      "plugins": ["functional-hmr", "transform-react-jsx-source"]
    }
  }
}

HMR is definitely enabled and it works with classes as well. I'm just having the automatically set up components from storybook. the Welcome is a class and works fine. But the Button is a functional component and it doesn't change.

from babel-plugin-functional-hmr.

MrLoh avatar MrLoh commented on July 17, 2024

Is there any way to see in the react native debugger wether the component actually got transformed?

from babel-plugin-functional-hmr.

MrLoh avatar MrLoh commented on July 17, 2024

Ok, I think I got it to work. The problem is, that editing the .babelrc won't actually change the setup, unless you start the packager with yarn start --reset-cache to clean the transform cache. Super confusing, cost me several hours.

from babel-plugin-functional-hmr.

bvic23 avatar bvic23 commented on July 17, 2024

Sorry for the inconvenience and thanks for getting back. I had a busy week I planned to fix tonight! Anyway I've updated the readme with your finding! Thanks.

from babel-plugin-functional-hmr.

bvic23 avatar bvic23 commented on July 17, 2024

I found out why cache reset did not come into my mind: RN packager is so different from React's webpack whenever I have any trouble (warnings, red screens, missing transforms) I immediately run the following script before debugging:

#!/bin/sh
rm -rf node_modules/
yarn install
watchman watch-del-all
rm -rf $TMPDIR/react-*

from babel-plugin-functional-hmr.

MrLoh avatar MrLoh commented on July 17, 2024

Yes it’s really f* up, so much undeterministic behavior. I really love React Native, but the dev experience is so much worse as compared to web. I’ll copy your script!

from babel-plugin-functional-hmr.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.