
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@remote-ui/react
Advanced tools
This library provides a custom React renderer that gives you the full power of React for your remote application, and provides an optional host layer that makes it easy for existing React apps to integrate a remote root. For a full overview of how `@remot
@remote-ui/react
This library provides a custom React renderer that gives you the full power of React for your remote application, and provides an optional host layer that makes it easy for existing React apps to integrate a remote root. For a full overview of how @remote-ui/react
can fit in with the different pieces of remote-ui, you can refer to our comprehensive example.
Using yarn
:
yarn add @remote-ui/react
or, using npm
:
npm install @remote-ui/react --save
render()
The main entrypoint for this package, @remote-ui/react
, provides the custom React renderer that outputs instructions to a @remote-ui/core
RemoteRoot
object. This lets you use the remote-ui system for communicating patch updates to host components over a bridge, but have React help manage your stateful application logic. To run a React ap against a RemoteRoot
, use the render
function exported by this library, passing in the remote root and your root React component:
// React usually has to be in scope when using JSX
import React from 'react';
// For convenience, this library re-exports several values from @remote-ui/core, like RemoteRoot
import {render, createRemoteRoot} from '@remote-ui/react';
// a host component — see implementation below for getting strong
// typing on the available props.
const Button = 'Button';
// Assuming we get a function that will communicate with the host...
const channel = () => {};
const remoteRoot = createRemoteRoot(channel, {
components: [Button],
});
function App() {
return <Button onClick={() => console.log('clicked!')}>Click me!</Button>;
}
render(<App />, remoteRoot);
As you add, remove, and update host components in your React tree, this renderer will output those operations to the RemoteRoot
. Since remote components are just a combination of a name and allowed properties, they map exactly to React components, which behave the same way.
createRemoteReactComponent()
In the example above, our Button
component was not strongly typed. Like with @remote-ui/core
’s createRemoteComponent
, We can use the createRemoteReactComponent
function from this library to create a strongly typed component to use. @remote-ui/react
’s API is the exact same as createRemoteComponent
(including the same type arguments), but the value returned is both a RemoteComponentType
and a ReactComponentType
, both with appropriate prop types.
import {createRemoteReactComponent} from '@remote-ui/react';
const Button = createRemoteReactComponent<'Button', {onPress(): void}>(
'Button',
);
// Type error, because onPress is missing!
const button = <Button>Save</Button>;
If you have a situation where you have separate packages for React and non-React components (e.g., to support the smaller bundle size of using only the core library), you can pass the result of calling @remote-ui/core
’s createRemoteComponent
to this version of the function, and the props will be inferred automatically.
import {createRemoteComponent as coreCreateRemoteComponent} from '@remote-ui/core';
import {createRemoteReactComponent} from '@remote-ui/react';
const Button = coreCreateRemoteComponent<'Button', {onPress(): void}>('Button');
const ReactButton = createRemoteReactComponent(Button);
// Still a type error!
const button = <Button>Save</Button>;
TODO: explain exports of @remote-ui/react/host
.
This package exports a helper type for extracting information from components created by createRemoteComponent
:
ReactPropsFromRemoteComponentType
accepts any type as a type argument and, if it is a remote component, returns its prop types when used as a React component.
import {
createRemoteComponent,
ReactPropsFromRemoteComponentType,
} from '@remote-ui/react';
const Button = createRemoteComponent<'Button', {onPress?(): void}>('Button');
type ButtonProps = ReactPropsFromRemoteComponentType<typeof Button>; // {onPress?(): void; children: ReactNode}
FAQs
This library provides a custom React renderer that gives you the full power of React for your remote application, and provides an optional host layer that makes it easy for existing React apps to integrate a remote root. For a full overview of how `@remot
The npm package @remote-ui/react receives a total of 116,079 weekly downloads. As such, @remote-ui/react popularity was classified as popular.
We found that @remote-ui/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.