Coder Social home page Coder Social logo

moroccanoss / react-stoon Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 10.0 15 KB

react-stoon is a handy toolbox of reusable Components that allow you to reduce boilerplate by writing less js inside of your React Components.

License: MIT License

JavaScript 100.00%

react-stoon's People

Contributors

amine-h avatar bigfanjs avatar soub4i avatar younesshakky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-stoon's Issues

add flatten flag to Repeat foreach

add a flag that flattens the prop that gets passed to Repeat's children

const MyList = (items) => {
   <Repeat foreach={items} flatten>
      <MyListItem />
   </Repeat>
}

const MyListItem = ({value}) => <Text>{value}</Text>

Show can't render multiple elements

Hi @Amine-H I like the new release, the helpers look clean ๐Ÿ‘

There is a little issue, Show supports only returning one element.

This will not work:

<Show if={true}>
  <ProjectItem />
  <p>Other element</p>
</Show>

React 16 supports this with Fragments, not sure if it will create compatibility issues with projects using older versions.

export default (props) => {
  const { if: visible, children } = props;
  if(visible){
    return <React.Fragment> {children} </React.Fragment>
  }

  return null;
}

Let me know if you have some solutions in mind.

Show controls my code & only renders React Components

Hi! nice idea ๐Ÿ‘ ๐Ÿฅ‡

I tried the Show helper and here are some thoughts:

Show only work for React components, For example, this will not work:

<Show $={"img"} if={imageLink != ""}>
  <img src={imageLink} />
</Show>

And while it works well for Components, the Show syntax mixes with the application logic ๐Ÿ˜ข
For example, JS conditional:

{ 
  project && <ProjectItem onDelete={this.deleteProject} project={project} />
}

After applying Show helper:

<Show
  $={ProjectItem}
  if={project}
  onDelete={this.deleteProject}
  project={project}
/>

In the code above Show dominated the component & it's props ๐Ÿ˜ˆ
instead, we could have this:

<Show if={project} />
  <ProjectItem onDelete={this.deleteProject} project={project} />
</Show>

In the last syntaxe Show will only decide if or not to render, without taking care of props or other stuff.

It would be cool if Show works only as a conditional helper & for both React and Dom elements.

Let me know what you think.

only Import components you need from react-stoon

We know generalized imports blow bundle sizes and increase the script evaluation and compilation time. So, In this issue I am requesting a new feature which helps you specify only the components you need to import.

import Show from "react-stoon/Show";
import Repeat from "react-stoon/Repeat";

I think we still end up loading some useless code even with module bundlers like Webpack's best optimization tricks like taking down dead code using tree shaking before we load our code to the browser. But because most of EcmaScript latest features are now available natively in the some browsers. Some people may not even bother bundling up their code and directly start importing their modules.

<script type="module" src="./script.js"></script>

I thought I would issue this before I start working on it.

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.