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

Effective Volto 2023 #793

Merged
merged 47 commits into from
Oct 1, 2023
Merged

Effective Volto 2023 #793

merged 47 commits into from
Oct 1, 2023

Conversation

sneridagh
Copy link
Member

No description provided.

@netlify
Copy link

netlify bot commented Sep 9, 2023

Deploy Preview for plone-training ready!

Name Link
🔨 Latest commit 99e4a21
🔍 Latest deploy log https://app.netlify.com/sites/plone-training/deploys/6519a63d654bd300097e5e5b
😎 Deploy Preview https://deploy-preview-793--plone-training.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sneridagh sneridagh changed the title Update getting started Effective Volto 2023 Sep 9, 2023
## Using a dataAdapter pattern

Sometimes is useful to adapt the incoming data to other data format, structure or type.
You can use the dataAdapter pattern in `BlockDataForm` as this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern will cause confusion.

Why is the BlockDataForm looking for a dataAdapter for a certain block? (it's not explained that the BlockDataForm is used internally by the teaser block).

It's not explained how to register the data adapter (although this would be obvious, in theory). The data adapter function uses CamelCase naming, usually reserved for components.

I think it's dangerous to have the data adapter directly call onChangeBlock. I think it's better if the purity of the data operations is kept. No side-effects. If the data adapter is called too late in the data "fixing" chain, then we need to figure out a solution to call it sooner, at the top of the chain, at the level of the "big form".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiberiuichim I completed the docs to make them more consistent and understandable.

Regarding the purity... we are already calling it virtually everywhere, since the default pattern is:

          onChangeField={(id, value) => {
            onChangeBlock(block, {
              ...data,
              [id]: value,
            });
          }}

in all places. So calling it inside the dataAdapter is "legit", right? Granted, it could be handled better, but as a general improvement of the BlockDataForm.


function MyComponent(props) {
const [myVal, setMyVal] = useAtom(mySharedStateAtom);
return <button onClick={() => setMyVal(val + 1)}>Count up</button>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@sneridagh sneridagh marked this pull request as ready for review October 1, 2023 17:02
@sneridagh sneridagh merged commit 6087185 into main Oct 1, 2023
5 checks passed
@sneridagh sneridagh deleted the effectiveVolto2023 branch October 1, 2023 17:11
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.

2 participants