Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@monokle/tree-navigator

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@monokle/tree-navigator

React library for rendering tree structures based on the Redux store.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
5
Weekly downloads
 
Created
Source

@monokle/tree-navigator

Create tree structures based on your Redux state then easily render it in React.

Features:

  • Define sections (tree levels) and section items (tree nodes) using simple blueprint objects
  • Virtualized rendering of trees
  • Expand & collapse sections
  • Customize both sections and items with your own components

Usage



// RTK Listeners setup
export const listenerMiddleware = createListenerMiddleware();
export type AppStartListening = TypedStartListening<RootState, AppDispatch>;
export type AppStopListening = TypedStopListening<RootState, AppDispatch>;
export const startAppListening = listenerMiddleware.startListening as AppStartListening;
export const stopAppListening = listenerMiddleware.stopListening as AppStopListening;

// configure the redux store
const store = configureStore({
  reducer: combineReducers({
    // add the reducer created by rtk-tree-navigator
    ...getTreeNavigatorReducer(),
    // other reducers...
  }),
  middleware: getDefaultMiddleware => getDefaultMiddleware().prepend(
    listenerMiddleware.middleware
  ),
});

// rtk-tree-navigator setup
setupTreeNavigators({
  startListening: startAppListening,
  stopListening: stopAppListening,
  dispatch: store.dispatch
})

// create your first tree navigator
export const treeNavigator = createTreeNavigator("Resources");

// register a section
treeNavigator.registerSection("sectionId" {
  scope: (state) => state.main.resources,
  build: {
    label: "Some section
  },
  items: {
    build: scope => scope.resources.map((resource) => {
      return {
        id: resource.id,
		label: resource.name,
		props: {
		  isSelected: resource.isSelected
		}
	  }
    }),
  }
});

// register a subsection
treeNavigator.registerSection("sectionId.subsectionId", {/*...*/});

// unregister a section
treeNavigator.unregisterSection('id');

// the tree navigator can be rendered by using the Renderer component
<treeNavigator.Renderer />

FAQs

Package last updated on 10 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc