Question: do "previous mapper results" rely on order of keys
See original GitHub issueGiven the following code snippet from the readme:
const Composed = adopt({
cart: <Cart />,
user: <User />,
shippingRates: ({ user, cart, render }) => (
<ShippingRate zipcode={user.zipcode} items={cart.items}>
{render}
</ShippingRate>
)
})
How do you know in which order to apply the render prop components? Does this rely on the order of keys returned from Object.keys(mapper)
call here?
As far as I know, object property order is not guaranteed. Asking because I’d love to use this library, but wondering if this could lead to some nasty (maybe cross browser) bugs.
Example of what could go wrong
const First = ({ children }: FirstProps) => children("foo");
const Second = ({ first, children }: SecondProps) => children(`${first}bar`);
const Display = ({ first, second }: DisplayProps) => (
<div>
First: {first}
<br />
Second: {second}
</div>
);
const Composed = adopt({
first: <First />,
second: ({ first, render }) => <Second first={first}>{render}</Second>
});
const ComposedInverse = adopt({
second: ({ first, render }) => <Second first={first}>{render}</Second>
first: <First />,
});
const App = () => (
<div style={styles}>
<h3>Correct order</h3>
<Composed>
{({ first, second }) => <Display first={first} second={second} />}
</Composed>
<h3>Inversed</h3>
<ComposedInverse>
{({ first, second }) => <Display first={first} second={second} />}
</ComposedInverse>
</div>
);
Result
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Is ordering of keys and values preserved in Elixir when you ...
Maps allow any value as a key. Maps' keys do not follow any ordering. While the Elixir website clearly states that Maps do...
Read more >Do Maps have an Reliable Relationship between keySet ...
The order of map elements is deterministic. You can rely on the order being the same in each subsequent execution of the same...
Read more >Map - JavaScript - MDN Web Docs - Mozilla
The keys in Map are ordered in a simple, straightforward way: A Map object iterates entries, keys, and values in the order of...
Read more >Section 4: Key Informant Interviews
Key informant interviews are qualitative in-depth interviews with people who know what is going on in the community. The purpose of key informant...
Read more >4. Working with Key/Value Pairs - Learning Spark [Book]
We can do this by running a map() function that returns key/value pairs. ... 4-9 through 4-11 to also implement the classic distributed...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@edorivai thanks for the heads up, it is very much appreciated. This lib reached a point where it should definitely address these uncommon but very relevant problems, if not by fixing them, at least providing people with information for the future 😉
I actually wanted to take a stab at this, only to find out that Typescript doesn’t support Map out of the box.
Meaning we have 3 options:
Map
What do you guys think?