Giter VIP home page Giter VIP logo

Comments (4)

christopherthielen avatar christopherthielen commented on April 19, 2024 1

My gut instinct is that this doesn't belong in UISrefActive. It seems trivial enough to do it "vanilla" style.

how can I do so that the class is always active irrespective of the parameters given as a default, so in essence be active as long as the state is in the dynamicView path

I might put the default parameter values on the dynamic state(s), then link to the state without any explicit values.

const state = { 
  name: 'dyn1',
  params: { 
   page: 0,
   filterType: { }
  }
}
                <UISref to={dynamicView}>

from react.

wilsonsergio2500 avatar wilsonsergio2500 commented on April 19, 2024

so so far, I just handled it vanilla

import { UISref, UIView, UISrefActive, StateService } from '@uirouter/react';
....
const stateService = this.props.transition.router.stateService as StateService;
const currentRoute = stateService.$current.name;

<UISref to={dynamicView} params={{ bucketId, page, viewtype  }}>
   <li role="presentation" key={index++} className={currentRoute == dynamicView && "active"  }>
                     ...
     </li>
</UISref>

I still be interested to learn other ways to handle it with UISrefActive, if any

from react.

elboman avatar elboman commented on April 19, 2024

I understand your needs, there currently isn't a way to override the isActive logic, but shouldn't be too much work to implement it as function prop in the component.

An example could be:

<UISrefActive class="active" key={index} isActive={() =>{}}>
  <UISref to={dynamicView} params={{ page, filterType }}><a>link</a></UISref>
</UISrefActive>

And the isActive prop would a function called with the router instance as argument, so one can implement whatever logic needed and return a bool.

Would like to know what @christopherthielen thinks about it.

from react.

eddiemonge avatar eddiemonge commented on April 19, 2024

As this issue is a bit old, it is being closed. If you feel like the problem reported is still valid, please add a comment saying it is still affecting you. We will reevaluate it and if it is valid we will reopen it.

Thank you for supporting and contributing to the project.

from react.

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.