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

WP-Builder: pass nested renderer to NavigatorLayout #26

Closed
bangank36 opened this issue Jul 8, 2023 · 2 comments
Closed

WP-Builder: pass nested renderer to NavigatorLayout #26

bangank36 opened this issue Jul 8, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@bangank36
Copy link
Owner

bangank36 commented Jul 8, 2023

Summary

  • Followed by the latest ObjectRenderer implementation, we will refactor the NavigatorLayout to expect JsonFormDispatch from its children and append into NavigatorScreen
  • Some advice about passing data from child to parent SF, advance tip SF
  • Some scenarios to address
    • Create a Context in NavigatorLayout to pass down method to update the screen data
    • Screen data should be an object (?) with property to the path name, eg: /address/country
    • ...

Reference

#22
#19

@bangank36 bangank36 self-assigned this Jul 8, 2023
@bangank36 bangank36 added the enhancement New feature or request label Jul 8, 2023
@bangank36
Copy link
Owner Author

bangank36 commented Jul 9, 2023

09 July 2023

  • Progress update: the new context help display the nested props UI into different views successfully, let's see what left here
    chrome-capture-2023-6-9

✅ Nested element now is display on different views and can be navigated back and forth using the buttons
✅ The form is functioning as the disclousure view can update the whole data as expected ( notice the right panel with serialized JSON data )
❌ The home page should display the primitive fields and nested field as NavigatorButton only, so far it display the whole form #28
/address screen is missing, somehow the setScreenContent did not update the screen array, this is strange because when debugging I can see the ObjectRenderer trigger the update for /address screen. 3de3c80#diff-970794900c344ca0cf5cb24ba03c6d1ffe72486f0c6acf848712d8116a327c23R62

  • Found a similar post on the issue on SF
    - Because the NavigatorLayout is re-rendered, that why the screenContent is reset? make the direct children screen only log the last child?
    - More discussion on that Preventing rerenders with React.memo and useContext hook. facebook/react#15156
  • This explain the situation understand that you are trying to set your local state and right away use this new value to set your value in your context SF
  • In short: Since the screenContent value is depending on the last value, we need to use it in a callback, more on the discussion https://stackoverflow.com/a/54069332
  • Example ![Image](https://github.com/bangank36/WP-Builder/assets/10071857/f22a2880-3bb1-4fd3-b537-8317f5961cc1)

@bangank36
Copy link
Owner Author

Closed this as the PR has been merged and will create follow-up ticket for the primitive and nested fields issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant