Reactive
  • Introduction
  • Reactivity Basics
  • Reactive Components
    • component()
    • ReactiveBoundary
  • API Reference
  • Reactivity
    • Reactivity API: Core
    • Reactivity API: Utils
    • Reactivity API: Advanced
  • Reactive Components
  • Links
    • GitHub
    • Sandbox
Powered by GitBook
On this page
  • Getting Started
  • Installation
  • Example

Was this helpful?

Introduction

NextReactivity Basics

Last updated 2 years ago

Was this helpful?

Getting Started

Reactive aims to provide concise, intuitive way of writing react applications with high performance, embracing a reactivity system and mutations. By taking advantage of reactivity, it also introduces a new way of creating functional components addressing many of the mental complexity brought by functional components with hooks api.

That means no useEffect, no useMemo/useCallback no useState and no redundant repeated renders!!

Reactive is based on a reactivity system. It tracks mutations on a reactive data, making sure only necessary components are re rendered, which eventually leads to a highly optimized application out of the box without worrying about pure components, memoization or immutability.

Installation

npm i @re-active/react

Example

import { computed, component, reactive } from '@re-active/react';

export const UserCard = component(() => {
  const user = reactive({
    name: 'John',
    lastName: 'Doe',
  });

  const fullName = computed(() => `${user.name} ${user.lastName}`);

  return () => (
    <div>
      <h2>Welcome {fullName.value} !</h2>
      <label>
        Name:
        <input
          value={user.name}
          onChange={(e) => (user.name = e.target.value)}
        />
      </label>
      <label>
        LastName:
        <input
          value={user.lastName}
          onChange={(e) => (user.lastName = e.target.value)}
        />
      </label>
    </div>
  );
});

Reactive also introduces a new but familiar way of defining components () heavily inspired by Vue 3 composition API. As a matter of fact, reactivity system is based on package which is a very light library powering Vue3. It's also standalone and completely decoupled with Vue.js.

component
@vue/reactivity