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

@fluentui/react-jsx-runtime

Package Overview
Dependencies
Maintainers
0
Versions
463
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluentui/react-jsx-runtime

Custom JSX runtime for @fluentui/react-components

  • 0.0.0-nightly-20241028-0410.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
decreased by-8.04%
Maintainers
0
Weekly downloads
 
Created
Source

@fluentui/react-jsx-runtime

React JSX runtime for Fluent UI React

Fluent UI React requires the usage of a custom JSX runtime to support the slots API

Usage

[!NOTE] This custom JSX pragma should only be used in cases where you are trying to use the internal Fluent UI React slot API in conjunction with assertSlots().

If you are not using the internal slot API, don't use it.

In case you want to re-compose a component and redeclare its render method then this API will be necessary, learn more on Rendering a component with slots

To properly render a component with slots, our custom createElement method needs to be used instead of default React.createElement:

NOTE: It works with both automatic or classic jsxRuntime configuration.

React 17+

infers @jsxRuntime automatic

/** @jsxImportSource @fluentui/react-jsx-runtime */

import { assertSlots } from '@fluentui/react-utilities';

const renderButton_unstable = (state: ButtonState) => {
  const { iconOnly, iconPosition } = state;

  assertSlots<ButtonSlots>(state);

  return (
    <state.root>
      {iconPosition !== 'after' && state.icon && <state.icon />}
      {!iconOnly && state.root.children}
      {iconPosition === 'after' && state.icon && <state.icon />}
    </state.root>
  );
};

React 16

infers @jsxRuntime classic

/** @jsx createElement */

// in order to apply our custom `createElement` factory to jsx transforms, to support slot creation, we need to import it physically
import { createElement } from '@fluentui/react-jsx-runtime';

import { assertSlots } from '@fluentui/react-utilities';

const renderButton_unstable = (state: ButtonState) => {
  const { iconOnly, iconPosition } = state;

  assertSlots<ButtonSlots>(state);

  return (
    <state.root>
      {iconPosition !== 'after' && state.icon && <state.icon />}
      {!iconOnly && state.root.children}
      {iconPosition === 'after' && state.icon && <state.icon />}
    </state.root>
  );
};

FAQs

Package last updated on 28 Oct 2024

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