0.3.13 • Published 3 years ago

@redwood.dev/client v0.3.13

Weekly downloads
-
License
MIT
Repository
github
Last release
3 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

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.9

3 years ago

0.3.10

3 years ago

0.3.0

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.2.22

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.3

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago