Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step2 pr 입니다! #74

Open
wants to merge 14 commits into
base: realizer12
Choose a base branch
from
Open

Conversation

realizer12
Copy link

많이 늦어서 죄송합니다;;

리뷰어님 과제 진행하다가
한가지 궁금증이 생겨서 질문 남깁니다!

과제 중간에 compose navhost에서 아래와 같이 적용 했을때
화면 이동시 -> recomposition이 여러번 일어나는 것을 확인 하였습니다.

composable로 구성된 screen


NavHost(){
  composable(route = "이동경로" ){

  }
}

Recomposition이 일어난 부분 확인 (아래 사진 참고)
image

해당 Recomposition을 없애 보기 위해서, 검색하다가
nia에서 composable 처리를 확장 함수로 처리 하였길래
해당 방식으로 바꿔서 테스트 해보았습니다.

아래는 확장함수 예시


fun NavGraphBuilder.productListScreen(
    onProductItemClicked:(clickedProductId: Int) -> Unit,
    onShoppingCartIconClicked: () -> Unit,
){
    composable(route = ScreenRouteType.SHOPPING_ITEM_LIST.navRoute) {
        ProductListRoute(
            onProductItemClicked = { clickedProductId ->
                onProductItemClicked(clickedProductId)
            },
            onShoppingCartIconClicked = {
                onShoppingCartIconClicked()
            }
        )
    }
}

그랬더니 recompositon이 skip되는 것을 확인 할수 있었습니다.

Recomposition skip 확인 (아래 사진 참고)
image

단지 확장 함수로 바꾸었는데
요렇게 달라지는 이유를 잘모르겠습니다;;
혹시 관련해서 조언을 얻을수 있을까요??

이상입니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant