New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

refnew-react

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

refnew-react

refnew react binding.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

refnew-react

refnew bindings for react.

install

npm install refnew refnew-react

Usage

Basic

// index.ts
import { create } from "refnew-react";
import React from "react";
import ReactDOM from "react-dom";
import { App } from "./App";

export type State = {
  todos: {
    title: string;
    status: "in-progress" | "done";
  }[];
  user: {
    name: string;
    icon: string;
  };
};

const { Provider, Consumer, update } = create<State>();
export { Provider, Consumer, update };

ReactDOM.render(
  <Provider value={createInitialValue()}>
    <App />
  </Provider>,
  document.querySelector("#app")!
);
// App.ts
import { Consumer, State, update } from './';

const select = (state: State) => ({
  todos: state.todos
});
export const App = () => (
  <Consumer select={select}>
    {({ todos }) => (
      {todos.map(todo => <div onClick={onClick.bind(null, todo)}>{todo.title} - {todo.status}</div>)}
    )}
  </Consumer>
);

const onClick = (todo: { title: string; status: string; }) => {
  todo.status = 'done';
  update();
};

see

  • refnew

note

  • inspired by aweary/react-copy-write.
  • don't use production.

Keywords

react

FAQs

Package last updated on 13 Aug 2018

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