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

248
Views
Getting TypeError: undefined is not an object (evaluating '_mathjs.default.fraction'), React-Native

I get this error whenever I use 'mathjs'

TypeError: undefined is not an object (evaluating '_mathjs.default.fraction')

Basically my code is this

import React from 'react';
import {View, Button} from 'react-native';
import mathjs from 'mathjs';
const App = () => {
  return (
    <View>
      <Button
        title="TestButton"
        onPress={() => {
           console.log(mathjs.fraction(1, 2)); // equals to ½
         }}
        />
   </View>
  );
};

export default App;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Looking at the library's npm page, I think you need to use a named import, not the default one:

import { fraction } from 'mathjs';

Named exports won't show up as properties of the default export. You could use this syntax to get all the named exports:

import * as mathjs from 'mathjs;

Although unless you're actually using them all I don't recommend this, since I think it would defeat tree-shaking for your javascript bundle.

See import docs for more information.

over 4 years ago · Santiago Trujillo 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!