goreact

package module
v0.0.0-...-6a152cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoKey = Key{Has: false}

Functions

func DumpTree

func DumpTree(root Node) string

func FC

func FC(name string, target func() Node) *fcComponentNoProps

FC Functional Component without Props

func FCC

func FCC(name string, target func(children ...Node) Node) *fccComponent

FCC Functional Component with Children

func FCP

func FCP[T any](name string, target func(props T) Node) *fcComponent[T]

FCP Functional Component with Props

func FCS

func FCS[S any](name string, defaultState S, target func(state S, updateState func(S)) Node) *fcsComponentNoProps[S]

FCS Functional Component with State without Props

func FCSC

func FCSC(name string, target func(child Node) Node) *fcscComponent

FCSC Functional Component with a single child

func FCSP

func FCSP[S, T any](name string, defaultState S, target func(props T, state S, updateState func(S)) Node) *fcsComponent[S, T]

FCSP Functional Component with State and Props

Types

type ChildrenProps

type ChildrenProps struct {
	Children []Node
}

func (ChildrenProps) GetChildren

func (p ChildrenProps) GetChildren() []Node

type Component

type Component interface {
	// contains filtered or unexported methods
}

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(r RenderInterface) *Engine

NewEngine creates a new render engine

func (*Engine) Diff

func (e *Engine) Diff(NewNode *NodeData, currentNode *NodeData)

func (*Engine) DiffChildren

func (e *Engine) DiffChildren(oldChildren []Node, node *NodeData)

func (*Engine) ParseFragment

func (e *Engine) ParseFragment(node Node) []Node

func (*Engine) Render

func (e *Engine) Render(element Node)

func (*Engine) UpdateElement

func (e *Engine) UpdateElement(el *NodeData)

type IChildrenProps

type IChildrenProps interface {
	GetChildren() []Node
}

type Key

type Key struct {
	Key uint64
	Has bool
}

func NewKey

func NewKey(k uint64) Key

func (Key) GetKey

func (p Key) GetKey() (uint64, bool)

type Node

type Node interface {
	// contains filtered or unexported methods
}

func Fragment

func Fragment(children ...Node) Node

func NativeEl

func NativeEl(typ string, props any) Node

type NodeData

type NodeData struct {
	IsDirty bool
	Key     Key

	NativeTyp string
	Typ       Component
	Props     any

	Parent   *NodeData
	Children []Node

	NativeElement any

	State any
}

type RenderInterface

type RenderInterface interface {
	SetEngine(e *Engine)

	InsertNode(node *NodeData)
	RemoveNode(node *NodeData)

	UpdateElement(node *NodeData)
}

Directories

Path Synopsis
example
comp command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL