You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

redwood-client-test

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redwood-client-test

Client for interacting with Redwood nodes

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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>
    )
}

Keywords

p2p

FAQs

Package last updated on 08 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts