Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

rename industry to principles #376

Merged
merged 3 commits into from
May 25, 2021
Merged

rename industry to principles #376

merged 3 commits into from
May 25, 2021

Conversation

avsm
Copy link
Member

@avsm avsm commented May 24, 2021

Tweaks the menu text for the first two columns as well, still
working on the third one.

Closes #339

Tweaks the menu text for the first two columns as well, still
working on the third one.

Closes #339
@vercel
Copy link

vercel bot commented May 24, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/ocaml/v3-ocaml-org/7gtmMMDE5naLPTwpTBzn36awBYDo
✅ Preview: https://v3-ocaml-org-git-fork-avsm-rename-to-principles-ocaml.vercel.app

@@ -324,12 +324,12 @@ let make = (~content) => {
section.entries,
),
[
<h3 className="ml-6 mt-2 px-3 font-semibold text-gray-400 uppercase">
<h3 key="0" className="ml-6 mt-2 px-3 font-semibold text-gray-400 uppercase">
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed to suppress a warning in the HeaderNavigation, cc @jonludlam

Warning: Each child in a list should have a unique "key" prop.

Check the top-level render call using <nav>. See https://reactjs.org/link/warning-keys for more information.
    at h3
    at HeaderNavigation (webpack-internal:///./src/HeaderNavigation.js:17:23)
    at div
    at div
    at MainLayout (webpack-internal:///./src/MainLayout.js:19:24)
    at make (webpack-internal:///./src/App.js:15:25)
    at AppContainer (/Users/avsm/src/git/ocaml/v3.ocaml.org/node_modules/next/dist/next-server/server/render.js:28:861)

Copy link

Choose a reason for hiding this comment

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

We should probably restructure this so that only one key is needed, but you can just add a TODO in the source code, and one of us will do that when working on this source code in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just a single-item constant list though; do we need to do anything?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, the key is needed whenever you have a list of React elements, regardless of whether the list contains one or more elements.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's why I added a key="0" in this PR :-)

Copy link
Contributor

@rdavison rdavison May 24, 2021

Choose a reason for hiding this comment

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

Ok, I just had a second look at this code, and it became apparent to me that the key value you've used here would collide with the other siblings in the array. The key should actually be its index in the array, which in this case, is the final element, not the 0th element.

That being said, I think the whole block of code could be refactored to make it a more visually apparent that this is the case.

Copy link
Contributor

@rdavison rdavison May 24, 2021

Choose a reason for hiding this comment

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

Looking at it even more closely, it seems the even original implementation is incorrect. From what I can tell, the index is restarting from 0 for every nested array, and then the nesting is being flattened. That would indicate to me that there are 4 instances of key="0" here.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to add 'key' to the items after they're created? Seems easier to create the list, then once it's completely made do a final mapi to add the keys on.

Copy link
Contributor

@rdavison rdavison May 25, 2021

Choose a reason for hiding this comment

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

My best thought at the moment which doesn't involve threading an accumulator through a reduce function, or using a ref, would be to map each array element to a function of type int => React.element, and then do the Js.Array.mapi call at the end.

Copy link
Member Author

Choose a reason for hiding this comment

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

Followed up with an issue in #382 and reverted my key=0 change in 8719297 so I can unblock merging this larger PR.

@avsm
Copy link
Member Author

avsm commented May 24, 2021

It's missing a rename of pages/industry to pages/principles, doing that now.

@avsm
Copy link
Member Author

avsm commented May 24, 2021

Should be good for review now.

@avsm avsm merged commit 8868737 into ocaml:master May 25, 2021
@avsm avsm deleted the rename-to-principles branch May 25, 2021 12:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change 'Industry' to 'Principles'
3 participants