Giter Site home page Giter Site logo

Comments (3)

Unraveler avatar Unraveler commented on June 15, 2024

If you use ToogleButton without using a ToogleGroup, then pressed is respected. This is because ToogleGroup is testing the selectedName against the child pressed prop :

const childrenWithProps = React.Children.map(children, (child) => {
      // pass the press state through to child components
      return React.cloneElement(child, {
        pressed: this.state.selectedName === child.props.name
      });
    });

Check here for an example --> https://codesandbox.io/s/react-geo-pressed-forked-8nn45?file=/index.js

from react-geo.

simonseyock avatar simonseyock commented on June 15, 2024

Maybe pressed could be calculated like this:

this.stat.selectedName === undefined ? child.props.pressed : this.state.selectedName === child.props.name

But then selectedName would need to get updated after and this would allow multiple buttons to be pressed at once.
The current behaviour is definitely easier, but if it should stay this way it would be nice if the documentation could be updated.

from react-geo.

Unraveler avatar Unraveler commented on June 15, 2024

I agree on updating the Docs, it makes sense to have the group control the button that is pressed, but this is not at all clear

from react-geo.

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.