Giter Site home page Giter Site logo

custom component 'wrappers' about formatjs HOT 3 CLOSED

formatjs avatar formatjs commented on May 2, 2024
custom component 'wrappers'

from formatjs.

Comments (3)

caridy avatar caridy commented on May 2, 2024

can you explain more what the use-case is? why do you want to use a custom component implemented by yourself for the wrapper element?

from formatjs.

athibaud avatar athibaud commented on May 2, 2024

well, in the same way that <p> or <h*> tags have default styling and behaviour in browsers, you could want your own component which come with its own styles and event handlers..

the fact that you already let the user chose which html tag will wrap the react-intl component i thought it could be easily extended to having custom components wrap react-intl components.

we've gone the full css in js way and it seems like more people are going that direction.
so here is our use case: we have a Text component that we use for most of our text blocks which has default styling like line-height and ::selection etc. that component merges the style prop its passed with its internal default style.

so we'd like to be able to do something like this:

<ReactIntl.FormattedMessage
  message="hello {maintainer}"
  component={require('components/Text')}
  maintainer="caridy"
  style={{ color: blue }}
/>

rather than:

var Text = require('components/Text');
<Text
  style={{ color: blue }}>
  <ReactIntl.FormattedMessage
     message="hello {maintainer}"
     maintainer="caridy"
  />
</Text>

and have an 'extra' span in my dom tree...

from formatjs.

athibaud avatar athibaud commented on May 2, 2024

closing this one because as i mention here it has deeper implications than i thought. namely if the wrapper component needs specific props it would complicate the current implementation.

i'm convinced there is little use for this now. friday evening issue. bad idea :)

from formatjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.