replay-jsx
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

replay-jsx

Use JSX syntax with Replay

Installation

yarn add -D replay-jsx

Setup

Babel

Create a .babelrc

{
  "plugins": ["replay-jsx/babel"]
}

If you're using webpack make sure you have babel-loader setup. If you're using ts-loader, you can view an example of how to configure it here

Typescript

Update your tsconfig to have the following:

{
  "compilerOptions": {
    "target": "es6",
    "jsx": "preserve"
  }
}

To get the types for JSX properly working you just need to import replay-jsx anywhere in your project (such as your index.tsx file)

import "replay-jsx";

Usage

import { makeSprite } from "@replay/core";
 
const Player = makeSprite({
  render({ props }) {
    return (
      <>
        <circle radius={10} color={props.color} />
      </>
    );
  },
});
 
const Game = makeSprite({
  render() {
    return (
      <>
        <Player color="#ff0000" />
      </>
    );
  },
});

Readme

Keywords

none

Package Sidebar

Install

npm i replay-jsx

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

9.28 kB

Total Files

6

Last publish

Collaborators

  • mattjennings