Coder Social home page Coder Social logo

daangn / stackflow Goto Github PK

View Code? Open in Web Editor NEW
675.0 28.0 72.0 1.25 GB

๐Ÿงฑ Mobile-first stack navigator framework with composable plugin system

Home Page: https://stackflow.so

License: MIT License

TypeScript 97.29% JavaScript 2.71%
react webview stack framework mobile navigator plugin system typescript

stackflow's Introduction

Introduction

Karrotframe is rebranded with "Stackflow". View full documentation and demo on https://stackflow.so

Stackflow is a project that implements Stack Navigation UX, which is mainly used in mobile devices (iOS/Android, etc.) in a JavaScript environment. So, it can help to easily develop hybrid apps and webviews.

  • Stack screens and keep scrolling state.
  • It supports transition effects that stack up the screen and the transition effect that disappears when you go back.
  • Supports iOS-style swipe back.
  • It passes the necessary parameters to the screen to be switched.

So, what advantages does Stackflow have compared to the existing navigation library?

  • You can only use the state for stacks and transitions separately without UI. You can tear off the UI and use it as you like.
  • You can inject any additional extensions you want between lifecycles through the plugin interface.
  • Since the core logic and integration layers are separated, it can be integrated with various front-end frameworks. (Now only supports React)
  • Because render logic and UI can be injected from the outside, mobile webview and desktop development can be done in one codebase.
  • Server-Side Rendering is supported. (ReactDOMServer.renderToString)

Getting Started

$ yarn add @stackflow/core @stackflow/react
import ReactDOM from 'react-dom'

import { stackflow } from '@stackflow/react';

const { Stack, useFlow } = stackflow({
  // ...
});

const App: React.FC = () => {
  return (
    <Stack />
  );
};

ReactDOM.render(<App />, ...)

Integration Examples

To integrate Stackflow with a specific framework with routing capabilities, the framework requires an extension to manually call the preload API. However, Next.js does not officially support the preload API.

Contributors

To contribute new features or options to Stackflow, please check Contribution Guide

License

MIT

stackflow's People

Contributors

2woongjae avatar alwaysawake avatar cxz7720 avatar devhyunseok avatar dogdriip avatar dylanju avatar ginger-kang avatar github-actions[bot] avatar godsenal avatar gronxb avatar hajoeun avatar irrationnelle avatar jongwooha98 avatar jongwooo avatar junghyeonsu avatar kooku0 avatar malangcat avatar orionmiz avatar ranolp avatar scarf005 avatar seonghyeonkimm avatar simyunsup avatar skymins04 avatar ssi02014 avatar stump26 avatar tonyfromundefined avatar tooooo1 avatar xiniha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stackflow's Issues

[Karrotframe] Suggest plugin to fix refresh issue

This would be fallback plugin to fix refresh issue

import { PluginType, NavigatorPluginType } from '@karrotframe/plugin'
import React, {createContext, useContext, useState} from 'react'

export const ContextPersistentPathPlugin = createContext<{
    guideMessage: any
    setGuideMessage: (guideMessage: string) => void
}>(null as any)

export const PersistentPathPluginProvider: React.FC = (props) => {
    const [guideMessage, setGuideMessage] = useState('')
    return (
        <ContextPersistentPathPlugin.Provider value={{ guideMessage, setGuideMessage }}>
            {props.children}
        </ContextPersistentPathPlugin.Provider>
    )
}

export const usePersistentPlugin = (): PluginType  & {
    setGuideMessage: (params: string) => any;
    guideMessage: string;
} => {
    const {guideMessage, setGuideMessage} = useContext(ContextPersistentPathPlugin)
        return {
          lifeCycleHooks: {
            onInsertScreenInstance: async (ctx) => {
              if(ctx.ptr === -1 && ctx.screenInstance.screenId !== '/' && ctx.screenInstances.length === 0) {
                  const previousPathInfoString = localStorage.getItem('screenPath');
                  if (!previousPathInfoString) {
                      setGuideMessage('Can not go back anymore')
                      return;
                  }
                  const {currentScreenInstances, isMatchedPath } = JSON.parse(previousPathInfoString);

                  const hasHistoryStack = isMatchedPath === ctx.screenInstance.screenId;
                  if (!hasHistoryStack) {
                      setGuideMessage('Can not go back anymore')
                      localStorage.removeItem('screenPath');
                      return;
                  }

                  const previousScreenPathArr = Object.keys(currentScreenInstances).map(index => currentScreenInstances[index]);
                  const screenPath = [...previousScreenPathArr, {...ctx.screenInstance, id: (previousScreenPathArr.length + 1).toString(), nestedRouteCount: 0}]
                  ctx.options?.setScreenInstancePtr?.(-1 + previousScreenPathArr.length);
                  ctx.options?.setScreenInstances?.(screenPath)
              }
            },
              beforePush: async (ctx) => {
                const currentScreenInstances = ctx.screenInstances.reduce((acc: any, curr: any, index: number) => {
                    acc = {
                        ...acc,
                        [index+1]: curr
                    }
                    return acc
                }, {});
                const pathInfo = {
                    currentScreenInstances,
                    isMatchedPath: ctx.to
                }
                localStorage.setItem('screenPath', JSON.stringify(pathInfo));
              }
         },
            setGuideMessage,
            guideMessage
        }
}

export const persistentPathPlugin: NavigatorPluginType = {
    name: 'persistentPathPlugin',
    provider: PersistentPathPluginProvider,
    executor: usePersistentPlugin,
}

ScreenHelmet์˜ onTopClick ๊ด€๋ จํ•ด์„œ ๊ถ๊ธˆํ•œ ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

  1. ์•„๋ž˜ ์ฃผ์„์˜ ์ƒ๋‹จ๋ฐ”์˜ ์˜๋ฏธ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค. ใ…Žใ…Ž
  /**
   * ์ƒ๋‹จ๋ฐ”๋ฅผ ํด๋ฆญํ–ˆ์„๋•Œ ํ˜ธ์ถœ๋  ์ฝœ๋ฐฑ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค
   */
  onTopClick?: () => void
  • ์ƒ๋‹จ๋ฐ”์˜ ์˜๋ฏธ๊ฐ€ Navbar ์ „์ฒด๋ฅผ ์˜๋ฏธํ•˜๋‚˜์š”? ์•„๋‹ˆ๋ฉด, ์•„๋ž˜ ํ‘ธ๋ฅธ์ƒ‰ ์˜์—ญ์„ ์˜๋ฏธํ•˜๋‚˜์š”?

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2021-04-14 แ„‹แ…ฉแ„’แ…ฎ 8 10 51

  1. ํ‘ธ๋ฅธ์ƒ‰ ์˜์—ญ(navbarCenterMainEdge)
  • ์œ„ ๊ทธ๋ฆผ์—์„œ ํ‘ธ๋ฅธ์ƒ‰ ์˜์—ญ(navbarCenterMainEdge)์„ ํด๋ฆญํ–ˆ์„ ๋•Œ, ์ตœ์ƒ๋‹จ์œผ๋กœ ์Šคํฌ๋กค๋˜๊ฒŒ ํƒ€์ดํ‹€์„ ํด๋ฆญํ–ˆ์„ ๋•Œ๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ๋Š”๋ฐ,
    "๋„ค๋น„๊ฒŒ์ด์…˜์˜ ํƒ€์ดํ‹€" ํด๋ฆญํ–ˆ์„ ๋•Œ๋กœ ์•„๋‹Œ ํ‘ธ๋ฅธ์ƒ‰ ์˜์—ญ(navbarCenterMainEdge) ์ถ”๊ฐ€๋กœ ๋งŒ๋“œ์‹  ์ด์œ ์— ๋Œ€ํ•ด ์—ฌ์ญค๋ด๋„ ๊ดœ์ฐฎ์„๊นŒ์š”?

๊ธฐ๋Šฅ ๊ฑด์˜ํ•ด์š”!

ํ˜„ํ™ฉ

  • si๋กœ 1์ผ ๋• x๋ฒ„ํŠผ์ด ๋‚˜์˜ค๊ณ , 1 ์ด์ƒ์ผ ๋• ํ™”์‚ดํ‘œ ๋ฒ„ํŠผ์ด ๋‚˜์˜ค๋ฉด์„œ si๊ฐ€ ๋‚ฎ์€ ์ˆซ์ž๋กœ ์ด๋™ํ•ด์š”.

๋ฐฐ๊ฒฝ

  • ํ•œ ํŽ˜์ด์ง€ ์ปดํฌ๋„ŒํŠธ ๋‚ด์—์„œ step์ด๋ž€ ์ƒํƒœ๋กœ ํŽ˜์ด์ง€๋ฅผ ๊ทธ๋ฆฌ๊ณ  ์‹ถ์–ด์š”.
  • ๋ง๋ถ™์ด์ž๋ฉด, ์ดˆ๊ธฐ ์ƒํƒœ๋ฅผ step 1์œผ๋กœ ๋งŒ๋“ค๊ณ  step 2๋กœ ๋„˜์–ด๊ฐ€๋Š” ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ํ•˜๋‚˜์˜ ํŽ˜์ด์ง€ ์ด์ง€๋งŒ step 2์— ๋งž๋Š” ํŽ˜์ด์ง€๋ฅผ ๊ทธ๋ฆฌ๊ณ  ์‹ถ์–ด์š”.
  • ๊ทธ๋ฆฌ๊ณ  step 2์—์„œ ๋’ค๋กœ๊ฐ€๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ step 1์œผ๋กœ ๋ณด๋‚ด๊ณ  ์‹ถ์–ด์š”.
  • ์ฆ‰, step 1์ผ ๋• x ํ‘œ์‹œ๊ฐ€, step 2์ผ ๋• step 1์œผ๋กœ ๊ฐ€๋Š” ํ™”์‚ดํ‘œ๊ฐ€ ๋–ด์œผ๋ฉด ์ข‹๊ฒ ์–ด์š”.
    (์ง€๊ธˆ์€ ํ•œ ํŽ˜์ด์ง€์ด๊ธฐ ๋•Œ๋ฌธ์— step๊ณผ ์ƒ๊ด€์—†์ด ๋’ค๋กœ๊ฐ€๊ธฐ๊ฐ€ ๋ผ์š”)
  • ์ž์„ธํžˆ ๋งํ•˜๋ฉด, useState๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ step 2๋กœ ๊ฐ€๋Š” ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ setStep์œผ๋กœ step ์ด๋ž€ ์ƒํƒœ๋ฅผ 2๋กœ ๋งŒ๋“ค์–ด์ค„ ์ˆ˜ ์žˆ์ง€๋งŒ
  • ๋’ค๋กœ๊ฐ€๊ธฐ๋ฅผ ๋ˆ„๋ฅผ ๋• setStep์„ ํ•ด์ค„ ์ˆ˜๊ฐ€ ์—†์–ด์š”.

๊ฑด์˜

  • ๋’ค๋กœ๊ฐ€๊ธฐ ๋ฒ„ํŠผ์— ๊ธฐ๋Šฅ์„ ๋„ฃ์„ ์ˆ˜ ์žˆ์œผ๋ฉด ์ข‹๊ฒ ์–ด์š”.
  • ์˜ˆ๋ฅผ ๋“ค์–ด setStep์„ ๋„ฃ์–ด step์„ 1๋กœ ๋ณ€ํ˜• ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค ๊ฐ™์ด์š”!
  • ์•„๋‹ˆ๋ฉด ํ•œ ํŽ˜์ด์ง€ ๋‚ด์—์„œ ๋˜ ๋‹ค๋ฅธ si๊ฐ€ ์žˆ์–ด ์ „์ฒด ํ๋ฆ„๊ณผ ๋ณ„๊ฐœ๋กœ ํ•ด๋‹น ํŽ˜์ด์ง€์—์„œ ์บ๋กฏํ”„๋ ˆ์ž„์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์–ด์š”!

Depth๋ณด๋‹ค ๋” ํฐ ๊ฐ’์„ pop ํ•  ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ

page depth๊ฐ€ 0์ผ ๋•Œ pop์„ ํ•˜๊ฑฐ๋‚˜, depth๊ฐ€ 1์ผ ๋•Œ pop(2)๋ฅผ ํ•˜๋Š” ๋“ฑ, depth๋ณด๋‹ค ํฐ ๊ฐ’์„ pop ํ•˜๋ ค ํ•  ๋•Œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
์ด ๋ถ€๋ถ„์— ๋Œ€ํ•ด์„œ depth๊ฐ€ 0์ผ ๋•Œ popํ•˜๋ ค ํ•˜๋ฉด ๋ฌด์‹œํ•˜๊ณ , depth๋ณด๋‹ค ํฐ ๊ฐ’์„ popํ•˜๋ ค ํ•˜๋ฉด ๋ฌด์‹œํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์œผ๋ฉด ํ•ด์š”.

์•„๋ž˜ ์ฝ”๋“œ์—์„œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๊ณ  ์žˆ์–ด์š”.

// useNavigator.ts in pop at line 96:5
// Cannot read property 'id' of undefined

const promise = store.screenInstancePromises.get(targetScreenInstance.id)

[Navigator] Support Web Browser environment

์ง€๊ธˆ await push() ์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ฒฝ์šฐ "์•ž์œผ๋กœ ๊ฐ€๊ธฐ" ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋ฌธ์ œ๊ฐ€ ๋  ์ˆ˜ ์žˆ์–ด์š”. ํ˜„์žฌ Promise๋ฅผ ํ†ตํ•ด Imperativeํ•˜๊ฒŒ ๋‹ค์Œ ํ™”๋ฉด์œผ๋กœ๋ถ€ํ„ฐ ์ฝœ๋ฐฑ์„ ๋ฐ›๋Š”๋ฐ, ์ด๊ฑธ ์„ ์–ธ์ ์œผ๋กœ ๋ฐ”๊ฟ”๋‚ด์•ผํ•ด์š”. v1 ๋กœ๋“œ๋งต์— ํฌํ•จ.

as-is:

const { push } = useNavigator()
  
const onClick = async () => {
  // ์•ž์œผ๋กœ ๊ฐ€๊ธฐ ํ›„ Submitํ•˜๋ฉด ์ด ์ฝœ๋ฐฑ์— ๊ฑธ๋ฆฌ์ง€๋ฅผ ์•Š์Œ.
  const data = await push(...)
  console.log(data)
}

to-be(Pseudo Code):

const { push } = useNavigator({
  onPopped(from, data) {
    switch (from) {
      case '...':
        console.log(data)
        break
    }
  }
})

const onClick = () => {
  push(...)
}

CONTRIBUTING.md ๋‚ด์šฉ ์ถ”๊ฐ€ ์ œ์•ˆ

๊ฒฝํ—˜

๋ฉ”์ธํ…Œ์ด๋„ˆ ๋ถ„๋“ค์€ ์–ด๋–ค IDE๋ฅผ ์“ฐ์‹ค์ง„ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ, ์ € ๊ฐ™์€ ๊ฒฝ์šฐ์—” vscode๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
๊ธฐ์—ฌํ•˜๊ธฐ ์œ„ํ•ด karrotframe์„ ํด๋ก  ๋ฐ›๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์—ด๋ฉด ์•„๋ž˜ ์‚ฌ์ง„๊ณผ ๊ฐ™์ด IDE๊ฐ€ ํŒจํ‚ค์ง€ ์ธ์‹์„ ๋ชปํ•ฉ๋‹ˆ๋‹ค.
image
๊ทผ๋ฐ ์‹ ๊ธฐํ•œ์ ์€ yarn && cd packages/karrotframe && yarn build:dts && yarn build:runtime --watch ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰์‹œ ๋ฌธ์ œ ์—†์ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ €๋Š” ์˜์•„ํ•œ ์ฑ„๋กœ IDE์˜ ์ œ ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•˜์ง€ ๋ชป ํ•œ์ฑ„ ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•˜๋ฉฐ ๊ธฐ์—ฌ๋ฅผ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

IDE๊ฐ€ ํŒจํ‚ค์ง€๋ฅผ ์ธ์‹ํ•˜๋„๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋งค์šฐ ๊ฐ„๋‹จํ•˜์˜€๋Š”๋ฐ์š”.

1๋ฒˆ ๋ฐฉ๋ฒ•

settings.json์— ์ž˜ ์„ค์ • ๋˜์–ด ์žˆ์–ด, vscode๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ์ฒซ ์˜คํ”ˆ ์‹œ ์šฐ์ธก ํ•˜๋‹จ์— ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฌธ๊ตฌ์™€ ํ•จ๊ป˜ TypeScript ๋ฒ„์ „์„ ๊ต์ฒดํ•˜๊ฒ ๋ƒ๋Š” ํŒ์—…์ด ๋œน๋‹ˆ๋‹ค.์ €๋Š” ์ด๋Ÿฐ๊ฑฐ ํ•จ๋ถ€๋กœ ์•ˆ ๋ˆ„๋ฅด๋Š” ์„ฑ๊ฒฉ์ด๋ผ..
image

allow๋ฅผ ํด๋ฆญ ํ›„ vscode๋ฅผ ๊ป๋‹ค ํ‚ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด IDE๊ฐ€ ์ธ์‹์„ ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
image

2๋ฒˆ ๋ฐฉ๋ฒ•

vscode๋ฅผ ์ผœ๋…ผ ์ƒํƒœ์—์„œ, โŒ˜ + โ‡ง + P๋ฅผ ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์ƒํƒœ๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.
image

ํ•ด๋‹น ์ž…๋ ฅ์ฐฝ์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ฑ„์›Œ์ฃผ๊ณ  ์—”ํ„ฐ๋ฅผ ๋ˆ„๋ฅด๋ฉด,
>TypeScript: Select TypeScript Version...

์•„๋ž˜ ์‚ฌ์ง„๊ณผ ๊ฐ™์€ ์„ ํƒ ์ฐฝ์ด ๋‚˜์˜ค๋Š”๋ฐ Use Workspace Version 4.1.5-pnpify ๋ถ€๋ถ„์„ ํด๋ฆญํ›„ vscode๋ฅผ ์žฌ์‹œ์ž‘ ํ•ฉ๋‹ˆ๋‹ค.
image

๊ฒฐ๋ก 

์ œ๊ฐ€ yarn2, workspace, pnp ๋“ฑ์— ๋Œ€ํ•œ ์ง€์‹์ด ์—†๋‹ค๋ณด๋‹ˆ ์ด๋Ÿฐ ์‹ค์ˆ˜๋ฅผ ๋ฒ”ํ–ˆ๋„ค์š”.
ํ˜น์‹œ๋ผ๋„ ์ €์™€ ๊ฐ™์ด IDE๊ฐ€ ์ธ์‹์„ ๋ชปํ•ด ๋‹นํ™ฉํ•ด ํ•  ์ˆ˜ ์žˆ๋Š” ๋ถ„๋“ค์„ ์œ„ํ•ด CONTRIBUTING.md์— ์œ„ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•˜๋Š”๊ฒŒ ์ข‹์ง€ ์•Š์„๊นŒ? ๋ผ๋Š” ์ƒ๊ฐ์„ ํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

์˜๊ฒฌ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

[iOS] Keyboard Avoiding View

iOS์—์„œ ํ‚ค๋ณด๋“œ๊ฐ€ ํ™œ์„ฑํ™”๋˜๋ฉด ์ƒ๋‹จ๋ฐ”๊ฐ€ ์œ„๋กœ ์˜ฌ๋ผ๊ฐ€๋Š” ๋ฌธ์ œ

1.0 Roadmap

Karrotframe 0.x ์€ ์›น ๊ธฐ๋ฐ˜ Transition Animation์„ PoCํ•˜๋Š” ์ˆ˜์ค€์—์„œ ๋‹น๊ทผ๋งˆ์ผ“ ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉ๋˜์—ˆ์–ด์š”. 1.0์€ ์ข€ ๋” ๋‚˜์€ ์ˆ˜์ค€์˜ ๊ฐœ๋ฐœ ๊ฒฝํ—˜, React Concurrent UI ํŒจํ„ด ์ง€์›, ํ”„๋กœ๋•์…˜ ์ˆ˜์ค€์˜ ์ฝ”๋“œ ์•ˆ์ •ํ™” ๋“ฑ์„ ํ•˜๋ฉด ์ข‹๊ฒ ์–ด์š”.

  • Renaming: Karrotframe์€ ์‚ฌ๋‚ด์—์„œ ์‚ฌ์šฉ๋˜๋˜ ํ”„๋กœ์ ํŠธ๋ช… ์ด์—์š”. ์ด๋ฅผ ๊ณ„์† ๊ฐ€์ ธ๊ฐ€๊ธฐ๋ณด๋‹ค๋Š” ์ข€ ๋” ์ง๊ด€์ ์ธ ์ƒˆ๋กœ์šด ์ด๋ฆ„์ด ํ•„์š”ํ•ด์š”.
  • Zero-dependency: MobX, React Transition Group ๋“ฑ ๋ฌด๊ฑฐ์šด Dependency๋“ค์ด ๋งŽ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ๋“ค์„ ๋ชจ๋‘ ๊ฑท์–ด๋‚ด์•ผํ•ด์š”.
  • Suspense ๋“ฑ React Concurrent UI ํŒจํ„ด ์ง€์›: Relay๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœ์ ํŠธ์—์„œ useTransition๊ณผ ํ•จ๊ป˜ ์“ธ ์ˆ˜ ์žˆ๋„๋ก Concurrent UI ํŒจํ„ด์„ ์ง€์›ํ•ด์•ผํ•ด์š”.
  • Test, Test, Test: ๋ˆ„๊ตฌ๋‚˜ ์† ์‰ฝ๊ฒŒ Contribution ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ…Œ์ŠคํŠธ๊ฐ€ ์ง€์›๋˜์–ด์•ผํ•ด์š”.

๊ธฐํƒ€ 1.0 ๋กœ๋“œ๋งต์— ์•„์ด๋””์–ด๊ฐ€ ์žˆ์œผ์‹  ๋ถ„๋“ค์€ ๋Œ“๊ธ€ ๋ถ€ํƒ๋“œ๋ ค์š”~

Suspense์˜ fallback์œผ๋กœ ScreenHelmet์„ ๋„ฃ์—ˆ์„ ๋•Œ ์˜๋„์น˜ ์•Š์€ ๋™์ž‘์„ ํ•จ

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ”๋“œ์—์„œ PullToRefresh๋ฅผ ํ•˜๋ฉด ScreenHelmet์ด ์‚ฌ๋ผ์ ธ์š”.

const MyPage = () => {
  return (
    <Base>
      <ScreenHelmet title="๋‚˜์˜ ํŽ˜์ด์ง€" />
      <PullToRefresh
        ...
      />
    </Base>
   )
}

const withSuspense = (Comp, LoadingComp) => {
  const WithSuspense = () => {
    return (
      <Suspense fallback={LoadingComp}>
        <Comp />
      </Suspense>
    )
  }

  return WithSuspense
}

export default withSuspense(
  MyPage,
  <>
    <ScreenHelmet />
    <PageLoading />
  <>
)

์ฐธ๊ณ ๋กœ appendRight์— ์ธ์Šคํ„ด์Šค๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด ์ •์ƒ ๋™์ž‘ํ•ด์š”.

Aug-09-2021 23-26-22

popAll ๊ธฐ๋Šฅ์ด ์žˆ์œผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”

๊ฐ™์€ ํŽ˜์ด์ง€์ธ๋ฐ ์ง„์ž…์ ์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ ์ง„์ž…์ ์— ๋”ฐ๋ผ ๋ถ„๊ธฐํ•ด์ฃผ๊ณ  ์žˆ๋Š”๋ฐ ๊ฐ€๋” ๋†“์น  ๋•Œ๊ฐ€ ์žˆ์–ด์š”

์—ด๋ ค์žˆ๋Š” screen์˜ depth๋งŒํผ pop์„ ํ•ด์ฃผ๋Š” popAll ํ•จ์ˆ˜๊ฐ€ ์ œ๊ณต๋˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”

[Android] ๋ฐฑ๋ฒ„ํŠผ ๋ˆ„๋ฅผ ์‹œ์— ์ฐฝ์ด ๋‹ซํ˜€๋ฒ„๋ฆผ

์„ธํƒ โ†’ ์ œ3์ž๋™์˜์ฐฝ โ†’ ๋‹น๊ทผ๋งˆ์ผ“์ œ3์ž๋™์˜์ฐฝ โ†’ ๋ฐฑ๋ฒ„ํŠผ

์ •์ƒ

์ œ3์ž๋™์˜์ฐฝ์ด ๋‹ซํžˆ๊ณ  ์›๋ž˜ ํ™”๋ฉด์œผ๋กœ ๋Œ์•„๊ฐ

๋ฒ„๊ทธ

์„ธํƒ ๋ฏธ๋‹ˆ๊ฐ€ ๋‹ซํ˜€๋ฒ„๋ฆผ

history.push๋ฅผ ํ•œ ๋’ค, navigator.push๋กœ ํŽ˜์ด์ง€๋ฅผ ์—ด์—ˆ์„๋•Œ ๋’ค๋กœ๊ฐ€๊ธฐ๊ฐ€ ์•ˆ๋˜๋Š” ์ด์Šˆ

  • history.push๋ฅผ ํ†ตํ•ด _si ์—†์ด ํŽ˜์ด์ง€๋ฅผ ๋ณ€๊ฒฝํ•œ ๋’ค, navigator.push๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ƒˆ page๋ฅผ ๋„์šฐ๋ฉด ์ƒˆ page์—์„œ ๋’ค๋กœ๊ฐ€๊ธฐ๋ฅผ ๋ˆ„๋ฅด๊ฑฐ๋‚˜, back swipe๋ฅผ ํ–‡์„ ๋•Œ history๋Š” pop์ด ๋˜์ง€๋งŒ, page๊ฐ€ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š์Œ

Card ์ปดํฌ๋„ŒํŠธ ๋‚ด๋ถ€ loading state์˜ ์‚ฌ์šฉ์ด ์ ์šฉ๋˜๋Š” ํŠน์ • ์ƒํ™ฉ์ด ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.

๋ฐฐ๊ฒฝ์ง€์‹

loading state

initial state -> props.isRoot
Card.tsx#27
image

loading state๊ฐ€ ์“ฐ์ด๋Š” ๋ถ€๋ถ„

Card.tsx#193
image

ํ˜„์žฌ ๋กœ์ง์ƒ loading state๊ฐ€ true์ผ ๊ฒฝ์šฐ Card.scss#37๋ฅผ ํ†ตํ•ด display: none์ด ์ ์šฉ๋˜๋Š”๊ฑธ๋กœ ํ™•์ธ๋ฉ๋‹ˆ๋‹ค.

๋งˆ์šดํŠธ ์‹œ loading -> false

mount๊ฐ€ ๋  ์‹œ setTimeout(cb, 0)์„ ํ†ตํ•ด loading state๋ฅผ false๋กœ ๋ฐ”๊ฟ”์ฃผ๋Š” ๋ชจ์Šต์ž…๋‹ˆ๋‹ค. Card.tsx#31
image

๊ถ๊ธˆ์ฆ

CardProps.isRoot ๊ฐ€ true์ผ ๊ฒฝ์šฐ ์œ„์™€ ๊ฐ™์€ ๋กœ์ง์ด ์ ์šฉ๋˜๋Š”๋ฐ(isRoot๊ฐ€ false์ด๋ฉด loading๋„ false์ด๋ฏ€๋กœ css ๋ฏธ์ ์šฉ Card.tsx#176) ์–ด๋–ค ํŠน์ • ์ƒํ™ฉ์—์„œ display: none์œผ๋กœ ํ•ด๋‹น ์—˜๋ฆฌ๋จผํŠธ๋ฅผ ๊ฐ์ถ”์—ˆ๋‹ค๊ฐ€ mount์‹œ ๋ณด์—ฌ์ค˜์•ผ ํ•˜๋Š” ์ƒํ™ฉ์ด ์˜ค๋‚˜์š”?

Screen ์ปดํฌ๋„ŒํŠธ unmount ๋™์ž‘ ๊ด€๋ จ ์งˆ๋ฌธ(+ ๋™์  ๋ผ์šฐํŒ…)

Screen ์ปดํฌ๋„ŒํŠธ unmount ๋™์ž‘ ๊ด€๋ จ ์งˆ๋ฌธ(+ ๋™์  ๋ผ์šฐํŒ…)

์งˆ๋ฌธ ํ•˜๊ฒŒ ๋œ ๋ฐฐ๊ฒฝ

ํ† ์ด ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋Š” ์ค‘์— ๋กœ๊ทธ์ธ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ผ์šฐํŒ… ์‹œํ‚ค๊ณ  ์‹ถ์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค:

<Navigator
    theme="Cupertino"
    onClose={() => {
      window.alert('๋‹ซ๊ธฐ ๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ์Šต๋‹ˆ๋‹ค')
    }}
>
    {login ? (
      <Screen key="login" path="/" component={LoginHome} />
    ) : (
      <Screen key="home" path="/" component={Home} />
    )}
</Navigator>

๋ฌธ์ œ์ 

์ œ๊ฐ€ ๊ธฐ๋Œ€ํ•œ ๋ฐฉ์‹๋Œ€๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ์™œ ์ด๋ ‡๊ฒŒ ๋™์ž‘ํ•˜๋‚˜ Screen.tsx๋ฅผ ์‚ดํŽด ๋ณด์•˜๋Š”๋ฐ, unmount ์‹œ mobx store์— ํ•ด๋‹น ์Šคํฌ๋ฆฐ์— ๊ด€ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ฑฐํ•ด ์ฃผ๋Š” ๋ถ€๋ถ„์ด ์—†์Šต๋‹ˆ๋‹ค.

๊ณ ๋ฏผ ํ•ด๋ณผ ์ 

์•„์ง ๋‚ด๋ถ€ ์ฝ”๋“œ๋ฅผ ๋‹ค ์ดํ•ดํ•˜์ง€ ๋ชป ํ•˜์˜€์ง€๋งŒ, "Screen ์ปดํฌ๋„ŒํŠธ๊ฐ€ unmount์‹œ store๋ฅผ ๋ณ€๊ฒฝ์‹œํ‚จ๋‹ค"๋ฅผ ๊ตฌํ˜„ํ•˜๋ ค๋ฉด ๊ฝค ๊ณ ๋ คํ•ด์•ผ ํ•  ์  ์ด ์žˆ๋‹ค๊ณ  ์ƒ๊ฐ์ด ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์Šคํฌ๋ฆฐ ํ•˜๋‚˜๊ฐ€ ์ œ๊ฑฐ ๋œ๋‹ค๋ฉด ์ˆœ์„œ๊ฐ€ ๊ผฌ์ด๊ฒŒ ๋˜์–ด _si ๋˜๋Š” screenInstance.id ๋“ฑ์˜ ๊ฐ’์˜ ๊ด€๊ณ„์— ์ด์Šˆ๊ฐ€ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
์œ„ ๊ณ ๋ฏผ์— ๋Œ€ํ•œ ์˜๊ฒฌ ๋˜๋Š” ๋™์  ๋ผ์šฐํŒ…์„ ๊ตฌํ˜„ํ•˜๋Š”(์ œ ๋ฐฉ์‹์ด ํ‹€๋ ธ์„ ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.) ๋‹ค๋ฅธ ๋ชจ๋ฒ” ์‚ฌ๋ก€๊ฐ€ ์žˆ๋Š”์ง€ ์—ฌ์ญค๋ณด๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค!

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. โ˜บ๏ธ

await push() & pop.send() ์‚ฌ์šฉ ์‹œ history pop๋ณด๋‹ค promise resolve๊ฐ€ ๋จผ์ € ์‹คํ–‰๋จ

  • await push() & pop.send() ์‚ฌ์šฉ ์‹œ history pop๋ณด๋‹ค promise resolve๊ฐ€ ๋จผ์ € ์‹คํ–‰๋˜๊ธฐ ๋•Œ๋ฌธ์—,
const response = await push<ROUTE_EVENT>(FRANCHISE_REGISTER_PATH)
        
replace(CREATE_JOB_POST_PATH)

์™€ ๊ฐ™์€ ์ฝ”๋“œ์—์„œ route๊ฐ€ ์ •์ƒ๋™์ž‘ํ•˜์ง€ ์•Š์Œ

  • setTimeout์„ ์ถ”๊ฐ€ํ•ด๋„ ํƒ€์ด๋ฐ์„ ์ •ํ™•ํ•˜๊ฒŒ ์žก์„ ์ˆ˜ ์—†์Œ

[๊ณตํ†ต] history.push ์‚ฌ์šฉ ํ›„ replace ์‹œ history๊ฐ€ ๊ผฌ์ž„

ex)

Main (Navigator.push) -> 
CreatePost(history.push) -> 
page1(history.push)  -> 
page2(Navigator.replace) ->  
bizMain(Navigator.pop) -> 
Main 
  • ์ด ํ”Œ๋กœ์šฐ ๋Œ€๋กœ ํ–ˆ์„๋•Œ, ๋งˆ์ง€๋ง‰ pop์„ ํ–ˆ์„๋•Œ Main์œผ๋กœ ์ฃผ์†Œ๊ฐ€ ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๊ณ  CreatePost์ฃผ์†Œ๋กœ ๋Œ์•„๊ฐ€๊ณ , Screen๋งŒ ์ •์ƒ์ ์œผ๋กœ rendering๋˜๋Š” ์ด์Šˆ
  • Screen์ž์ฒด๋Š” ์ •์ƒ์ ์œผ๋กœ pop๋˜์–ด ๋ณด์ด์ง€๋งŒ path๊ฐ€ replace์ „์˜ path๋กœ ๋ณ€๊ฒฝ๋จ

Screen Shot 2020-12-08 at 7 22 08 PM

iOS + HashRouter Problem

await push๋ฅผ ํ†ตํ•ด ๋ฉ”๋‰ด ์ ‘๊ทผ ํ›„ pop() ์‹คํ–‰์‹œ (๋ฐฑ๋ฒ„ํŠผ, ์Šค์™€์ดํ”„๋ฐฑ) Promise๊ฐ€ resolve๊ฐ€ ์•ˆ๋จ.

Breakpoint ์ฐ์œผ๋ฉด์„œ ๋””๋ฒ„๊น…์‹œ์—๋Š” ์ž‘๋™์ด ์ž˜ ๋จ.

[Navigator] replace without animate option doesn't work after using history.push

navigator.replace without animate option doesn't work after using history.push

In my opinion, when using history.push, _si is missing.
And, Because navigator.replace with animation doesn't set _si, karrotframe route also doesn't work

[ex flow]
page load -> history.push('/same-path?with-query-string') -> navigator.replace(/some-other-path) -> the page is not changed

Navigator์˜ replace๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์Œ

  • ํŽ˜์ด์ง€ ๋ฃจํŠธ(_si=1)์—์„œ replace({ animate: true }) ์‹œ ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์•„์š”.
  • replace์— ์˜ต์…˜์œผ๋กœ { animate: true }๋ฅผ ์ฃผ๋ฉด _si๊ฐ€ +2์”ฉ ์˜ค๋ฅด๊ณ , { animate: false }๋ฅผ ์ฃผ๋ฉด _si๊ฐ€ ๋ณ€ํ•˜์ง€ ์•Š์•„์š”.

replace ์• ๋‹ˆ๋ฉ”์ด์…˜ ์˜๊ฒฌ ์ œ์‹œ

replace

์ฒซ๋ฒˆ์งธ๊ฐ€ ์•„๋‹Œ ํŽ˜์ด์ง€์—์„œ replace ํ•˜๋ฉด ํ™”๋ฉด์ด ์ƒˆ๋กœ ๋‚˜์™€์š” ๐Ÿ˜ญ
ํ˜น์‹œ ์ด๊ฑฐ๋ฅผ ์กฐ์ ˆ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”?

์ฒซ๋ฒˆ์งธ๊ฐ€ ์•„๋‹Œ ํŽ˜์ด์ง€์—์„œ replace ๋ฅผ ํ•  ๊ฒฝ์šฐ

์ฒซ๋ฒˆ์งธ ํŽ˜์ด์ง€์—์„œ replace ๋ฅผ ํ•  ๊ฒฝ์šฐ

[๊ณตํ†ต] replace ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ง€์›ํ•˜๊ธฐ

์˜ˆ์ƒ ์‹œ๋‚˜๋ฆฌ์˜ค

๊ธ€์“ฐ๊ธฐ ํผ์„ ์ฒซ Entry ๋“ค์–ด์™€์„œ, ๊ธ€์“ฐ๊ธฐ๋ฅผ ์™„๋ฃŒํ–ˆ์„๋•Œ ํ•ด๋‹น ๋ฏธ๋‹ˆ์•ฑ์˜ ํ™ˆํ™”๋ฉด์œผ๋กœ ๋ณด๋‚ด๊ธฐ.
์• ๋‹ˆ๋ฉ”์ด์…˜๊ณผ ํ•จ๊ป˜, X ๋ฒ„ํŠผ์„ ์˜ฎ๊ฒจ์•ผ ๋œ๋‹ค.

ํ•„์š”ํ•œ ๊ธฐ๋Šฅ

replace() API๋ฅผ ํ™”๋ฉด ์ „ํ™˜ ์• ๋‹ˆ๋ฉ”์ด์…˜๊ณผ ํ•จ๊ป˜ ์ˆ˜ํ–‰ํ•˜๊ธฐ

์˜ˆ์ƒ API

replace('/', {
  animate: true,
})

๋˜๋Š”

replace('/').animate()

์ „์ž๊ฐ€ ๋” ๋‚˜์•„๋ณด์—ฌ์š”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.