-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Let's assume we have defined the following dictionary dict:
const dict = createDict({
hello: 'Hello {count}',
});Currently we access a dictionary entry like this:
<Trans {...dict('hello', { count })} />The downside of this approach is that function calls (at least those who do not create a JSX element) invalidates Flow type refinements: https://flow.org/en/docs/lang/refinements/#toc-refinement-invalidations
Because of that it might be an improvement to use a Dict function instead. Also you can say that this would be more a React like approach, because we use pure JSX.
import React from 'react';
import { createDict } from 'intlized-components';
const Dict = createDict({
hello: 'Hello {count}',
});
function Component() {
return <Dict name="hello" values={{ count }} />;
}Without values the new syntax would also be a little bit shorter:
<Dict name="hello" />
{/* vs. */}
<Trans {...dict('hello')} />Metadata
Metadata
Assignees
Labels
No labels