Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
Sharing components made with Native-Base between ReactJs and React Native Projects

I am trying to share components between a ReactJs and React Native project. I have been successful in being able to share components that use React Native, but project that use Native Base get errors. My setup is this:

I have a mono repo that holds the project. I installed React Native Web in my web project I made a shared folder in in my React Native code base. I made a symlink from my web src folder to the shared folder I updated babel configs to compile items in the shared folder

Here is an example of a component I am trying to share. Nothing too special ;)

import {Center, Text} from 'native-base';

const Test = () => {
  return (
    <Center>
      <Text>hello world!</Text>
    </Center>
  );
};

export default Test;

I see this in devtools console:

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app

The above error occurred in the <ForwardRef(Center)> component:

Any idea how I can get components with native base to work in web. I should note that it works fine on mobile, where there is not a symlink.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The only way to share components between web and native mobile is with expo, or with react-native-web. I use react-native-web, and I am happy with the technology. Write once play everywhere (web, android & ios)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!