Comments (7)
Make sense, issue reopened
from eo-locale.
@morbidick Yes it is, but it allows to use React components as parameters for Text
component
from eo-locale.
@pret-a-porter That's actually an issue for vite for example, having react-dom/server
increases bundle size by 25% and it makes no sense to use the library
from eo-locale.
Yes it is, but it allows to use React components as parameters for Text component
@pret-a-porter Right, but that component won't have access to things like context, because it's rendered in isolation. That feels like a pretty big footgun.
from eo-locale.
AFAIK the "proper" way to handle it is to make Text return a fragment, and let react handle the rest. So, something like the following:
// messages: { hello: 'Hello, {name}. Nice to meet you!' }
// a Text like this:
<Text id="hello" name={<SomeComponent />} />
// should output (return) this:
<>{"Hello, "}<SomeComponent />{". Nice to meet you!"}</>
from eo-locale.
Unfortunately it does not cover case, when string contains html tags. React fragments does not support dangerouslySetInnerHTML
and this proposal reactjs/rfcs#129 still in RFC stage for more than two years.
from eo-locale.
yes, html strings would probably need to be parsed into a react tree (a la react-html-parser
). not ideal, but i don't think there's a way around it if you want to have <Elements>
work properly. i guess at least its cacheable (the translations don't really change much) so shouldn't be a big perf problem
from eo-locale.
Related Issues (20)
- React 18 HOT 5
- Does not seem to parse complex nested strings
- Validate and improve documentation HOT 8
- Can not format date, number, and plural in React Native HOT 3
- Differences in Preact API HOT 6
- Implement unit tests for @eo-locale/preact
- Implement integration with Svelte
- Implement integration with Vue
- Cannot read property 'getMessageById' of undefined HOT 4
- Wrongly raise `id missing` error when translation === id HOT 2
- Error [ERR_REQUIRE_ESM]: Must use import to load ES Module HOT 6
- Messages extration for translation HOT 6
- React v17 HOT 5
- [question]: Is there any way to use a component inside a message? HOT 6
- Does not handle ICU offset HOT 2
- Refactor tests to React Testing library
- `select` role don't support `other` case HOT 2
- Need to use 'fullySpecified' Webpack 5 config to use this library
- No Error on missing Translation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eo-locale.