Cover image for Announcement about @laststance/use-app-state

Announcement about @laststance/use-app-state

malloc007 profile image Ryota Murakami Updated on ・2 min read


That's it! and about this React library

This is 808byte light weight package for useAppState hook.

Freely pass and receive values between separated components.



npm install @laststance/use-app-state
# or
yarn add @laststance/use-app-state

TypeScript Example

// index.tsx
import React, { ReactElement } from 'react'
import ReactDOM from 'react-dom'
import Provider, { useAppState } from '@laststance/use-app-state'

interface Food {
  id: string
  name: string

type FoodList = Food[]

interface AppState {
  FoodList: FoodList

let initialAppState: AppState = {
  foodList: []

const App = () => {
const [appState, setAppState] = useAppState<AppState>() // pass appState object type as a generics
const item1: Food = {id: 'j4i3t280u', name: 'Hamburger'}
const item2: Food = {id: 'f83ja0j2t', name: 'Fried chicken'}
setAppState({foodList: [item1, item2]})

const foodListView: ReactElement[] = appState.foodList.map((f: Food) => <p key={f.id}>{f}</p>)

return (<div>{foodListView}</div>)

    <Provider initialState={initialAppState}>

Edit @laststance/use-app-state Example


You can use it immediately without leaning if you have a common experience as a React developer.

I'm glad to hitting demand this post like who excited prototyping frequency and wanted **setState that regardless component boundary.

Thank you for reading the article, Follow Me! 🐦 and feel free to unsubscribe! πŸ€—

Posted on by:

malloc007 profile

Ryota Murakami


laststance.io FullStack TypeScript dev. Freelancer πŸ‘¨β€πŸ’» I'm in Tokyo but I'living on SF~Austin time zone. ✈️ My gig is eliminate all of Bullshit in the Software Dev.


markdown guide