-
Notifications
You must be signed in to change notification settings - Fork 6
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
Refactor state management #25
Conversation
src/ImageSelect/ImageBuilder.jsx
Outdated
const [repo, setRepo] = useState(""); | ||
const [builtImage, setBuiltImage] = useState(null); | ||
const { costumImage, setCustomImage } = useContext(SpawnerFormContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo - costumImage -> customImage ?
Ty @oliverroick. I'm OOO rest of the week, but I've invited @batpad to this repo so he should be able to review + merge as appropriate.
Correct, and the jankiness of figuring out 'when should the start button be enabled?' is what made me look for refactoring the state management. |
Addressed the feedback from @batpad and added a couple more changes:
|
@oliverroick - this is looking great and I think we should merge this. Some minor things:
The validation / error messaging and all the state management clean-ups are looking really great to me! Let's discuss and if it helps to move things forward, let's merge this, else we can wait for @yuvipanda to be back next week and see if he has any comments. |
@oliverroick noticed the |
To implement state management, I did a fair bit of refactoring and simplification of the code. Main changes include:
index.jsx
as the entry point for the form, to separate mounting the app to the DOM from the UI components. I added a new componentProfileForm
for rendering the overall formImageSelect
andResouceSelect
so we can separate functionality required for image selection only from the more generic resource selection.useSelectOptions
so it can be used across the various form components.I completely revamped the state management for the app to create a single source of truth that is accessible from all components below the context.
SpawnerFormProvider
so it’s accessible through out.Open questions:
canSubmit
flag, presumably as a simple way of form validation. I’d suggest we implement form validation and error messaging as well.