0.3.13 • Published 2 years ago

@redwood.dev/client v0.3.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Redwood.js

Redwood client

WIP

React hooks

import React, { useRef } from 'react'
import Redwood from '@redwood.dev/client'
import { RedwoodProvider, useRedwood, useStateTree } from '@redwood.dev/client/react'

const identity = Redwood.identity.random()

function App() {
    return (
        <RedwoodProvider
            httpHost="http://localhost:8080"
            identity={identity}
        >
            <ChatRoom />
        </RedwoodProvider>
    )
}

function ChatRoom() {
    const { redwoodClient } = useRedwood()
    const chatRoom = useStateTree('chat.redwood.dev/general')
    const textInput = useRef()

    function onClickSend() {
        redwoodClient.put({
            stateURI: 'chat.redwood.dev/general'
            patches: [
                '.messages[0:0] = ' + Redwood.utils.JSON.stringify({
                    sender: identity.address,
                    text:   textInput.current.value,
                }),
            ],
        })
    }

    return (
        <div>
            {chatRoom.messages.map(msg => (
                <div>
                    <div>{msg.sender}</div>
                    <div>{msg.text}</div>
                </div>
            ))}

            <input ref={textInput} />
            <button onClick={onClickSend}>Send</button>
        </div>
    )
}
0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.9

2 years ago

0.3.10

2 years ago

0.3.0

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.2.22

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.2.18

2 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

3 years ago

0.2.12

3 years ago

0.2.11

3 years ago

0.2.10

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.3

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago