Coder Social home page Coder Social logo

Make a HOC version about reflexbox HOT 7 CLOSED

jxnblk avatar jxnblk commented on May 18, 2024
Make a HOC version

from reflexbox.

Comments (7)

jxnblk avatar jxnblk commented on May 18, 2024

I've certainly been thinking about this. I was thinking more of having an API that looks something like this, but maybe there's good reason not to go with this approach:

<Box
  Component={Paper}
  {...boxProps}
  {...paperProps} />

The Box component would pass styles based on its props, then render Paper. Curious what you think

from reflexbox.

jgoux avatar jgoux commented on May 18, 2024

I think it's a matter of taste.

I prefer seeing a component's own props attached to its tag.
I also prefer seeing the tags tree composition, it reduces the cognitive load for me.

So I don't have a definitive answer for this, but I'm also curious of reading others opinions. ⁉️

from reflexbox.

mrtnbroder avatar mrtnbroder commented on May 18, 2024

I'm with @jgoux. I'd prefer seeing my props on the component tag.

from reflexbox.

jxnblk avatar jxnblk commented on May 18, 2024

I'm not opposed to the nested component approach. One thing that feels odd to me is that the jsx looks like two elements, but it's only generating one. Maybe that's an okay trade off in this situation.

from reflexbox.

jgoux avatar jgoux commented on May 18, 2024

We could also use a simple function:

import { AppBar, Paper } from "material-ui"
import { Box, Flex, box, flex } from "reflexbox"

const view = (props) =>

<Flex auto column>
  <AppBar />
  <Flex auto>
  {box({ auto: true })(
    <Paper>Left</Paper>
  )}
  {box({ auto: true })(
    <Paper>Right</Paper>
  )}
  </Flex>
</Flex>

With the partial application, you can even prepare common patterns :

import { AppBar, Paper } from "material-ui"
import { Box, Flex, box, flex } from "reflexbox"

const CustomBox = box({ auto: true })

const view = (props) =>

<Flex auto column>
  <AppBar />
  <Flex auto>
  {CustomBox(
    <Paper>Left</Paper>
  )}
  {CustomBox(
    <Paper>Right</Paper>
  )}
  </Flex>
</Flex>

from reflexbox.

jxnblk avatar jxnblk commented on May 18, 2024

The latest version 1.1.0 supports an is prop to pass components or elements to render as the root. I'll take a stab at wrapper component as well at some point.

from reflexbox.

jgoux avatar jgoux commented on May 18, 2024

Congrats for the release ! 👍

from reflexbox.

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.