Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda