Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

desmos-react

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

desmos-react

React wrapper for Desmos

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
148
increased by30.97%
Maintainers
1
Weekly downloads
 
Created
Source

desmos-react

This package provides a wrapper to use the Desmos API in React.

This package is not affiliated with Desmos. To use this in your product or obtain an API key, please reach out to partnerships@desmos.com.

Usage

import {Expression, GraphingCalculator, useHelperExpression} from "desmos-react";

function Demo() {
  return (
    <GraphingCalculator
      attributes={{className: "calculator"}}
      fontSize={18} keypad projectorMode
    >
      <Expression id="slider" latex="a=3" />
      <Point />
    </GraphingCalculator>
  );
}

/* useHelperExpression() can only be used inside <GraphingCalculator/>,
which is why this couldn't go in <Demo/> */
function Point() {
  const a = useHelperExpression({latex: "a"});

  let label;
  if (a > 0)
    label = "positive x-axis"
  else if (a < 0)
    label = "negative x-axis"
  else
    label = "origin";

  return (
    <Expression id="point" latex="(a,0)" label={label} showLabel />
  );
}

Reference

This package exports four components and two functions. See https://www.desmos.com/api/v1.6/docs/ for the full list of options.

<GraphingCalculator>, <FourFunctionCalculator>, <ScientificCalculator>

These load the various types of calculator Desmos provides. In addition to the Desmos options, these support an attributes prop to attach additional attributes to the <div> hosting the calculator.

Using ref on a calculator will return a ref to the calculator object, not the div. If you need access to the div, use the elt() function below.

<Expression>

Desmos expression. Put these inside <GraphingCalculator>.

useHelperExpression()

Hook for using helper expressions, see above for usage.

elt(calculator)

This returns the <div> hosting a calculator.

FAQs

Package last updated on 27 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc