Coder Social home page Coder Social logo

Comments (7)

vlack-coder avatar vlack-coder commented on July 22, 2024

Hi @jbroma starting a new react-native codebase with RePack, I was not able to use React-hook-form.
This is the only dependency that's a blocker from migrating my react native project meanwhile React-hook-form works well when it's installed in the super demo app.
Sorry that I tagged you, do you have any idea why it is so. Thank you

from repack.

vlack-coder avatar vlack-coder commented on July 22, 2024

Hi @jbroma after trial and error method, I was able to get it to work by removing \/ from
/node_modules(.*[/\])+react\//,
From this I guess it now matches the react-hook-form path.....
My question is that why is the / in the template config but not in the super app demo. Thank you

from repack.

jbroma avatar jbroma commented on July 22, 2024

Hi @vlack-coder,

We added that because it was too generic and some deps were picked up by mistake.

If changing that helped then adding a similar entry for just react-hook-form should work as well.

from repack.

jbroma avatar jbroma commented on July 22, 2024

@vlack-coder

I tried this today and I get no conflicts and it works out of the box in new projects. Perhaps something changed in react-hook-form that made it work out of the box? It shouldn't need transpiling as the library comes pretranspiled already.

I'll close this issue since you resolved your problems but also it's unclear that this was to default webpack.config we provide. Feel free to post an update here and we might reopen this and find the proper root cause of this.

from repack.

vlack-coder avatar vlack-coder commented on July 22, 2024

Hi @jbroma
So I tried it again with a new repo that has only react-hook-form installed and still encountered the same issue.....
NB: I'm using the Controller component from react hook form

Link to the repo - Github Repo

from repack.

jbroma avatar jbroma commented on July 22, 2024

Thanks for providing the repro, I'll check it out and get back to you to.

from repack.

jbroma avatar jbroma commented on July 22, 2024

Hi @vlack-coder,

I was able to reproduce your error, I was able to fix it and get it to work by adding the react-hook-form to transpiled modules inside of webpack.config. In my repro I think I didn't manage to encounter the error because I didn't use enough of the lib to get to this error. Both metro and webpack resolve correctly to the same entrypoint (node_modules/react-hook-form/dist/index.cjs.js), so aliasing shouldn't be neeed in this case.

Please do the following to resolve your issue:

rules: [
  {
    test: /\.[jt]sx?$/,
    include: [
      /node_modules(.*[/\\])+react\//,
      /node_modules(.*[/\\])+react-native/,
      /node_modules(.*[/\\])+@react-native/,
      /node_modules(.*[/\\])+@react-navigation/,
      /node_modules(.*[/\\])+@react-native-community/,
      /node_modules(.*[/\\])+expo/,
      /node_modules(.*[/\\])+pretty-format/,
      /node_modules(.*[/\\])+metro/,
      /node_modules(.*[/\\])+abort-controller/,
      /node_modules(.*[/\\])+@callstack\/repack/,
      /node_modules(.*[/\\])+react-hook-form/,  // <-- add this
    ],
    use: 'babel-loader',
  },
]

We should have a permament fix for this resolution & transpilation issues in the future, right now this is the only way to get around that.

from repack.

Related Issues (20)

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.