Skip to content
/ myra Public

Myra is a simple and small Typescript framework for building web interfaces.

License

Notifications You must be signed in to change notification settings

jhdrn/myra

Repository files navigation

Myra

Myra is (another) JSX rendering library. It is small, simple and built with and for Typescript.

npm CircleCI codecov Downloads gzip size install size

NPM

Myra is a JSX rendering engine implementing a subset of React, but with some differences.

Setup

Add a reference to myra, for example by installing it with NPM:

npm install --save myra

Add a tsconfig.json to your project:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "jsx": "react",
    "jsxFactory": "myra.h",
    "jsxFragmentFactory": "myra.Fragment",

    /* Optional, but recommended */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true
  }
}

Mounting a component

Use myra.mount to mount a component to the DOM:

    // Mount the component to a DOM element
    myra.mount(<MyComponent />, document.body) 

Implemented hooks

Memoized components

Use myra.memo to create a component that will only render if it's props have changed. The second argument is an optional comparison function to make a custom rendering decision:

    // Mount the component to a DOM element
    const MyMemoComponent = myra.memo<IProps>(props => <p></p>) 

Special props

Some props and events has special behavior associated with them.

  • The key prop should be used to ensure that the state of child components is retained when they are changing position in a list. When used with elements, it may also prevent unnecessary re-rendering and thus increase performance. It's value must be unique amongst the items in the list.
  • The class prop value will be set to the className property of the element.
  • The ref prop can be used to populate a ref's current value (see https://reactjs.org/docs/hooks-reference.html#useref)

License

MIT

Copyright (c) 2016-2024 Jonathan Hedrén

About

Myra is a simple and small Typescript framework for building web interfaces.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published