npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@talend/react-cmf

v10.1.0

Published

A framework built on top of best react libraries

Downloads

2,436

Readme

React content management Framework

This is a framework to help you to build configurable React App.

It provides a set of base APIs and patterns.

Travis CI NPM dependencies devdependencies

Requirements

Before trying CMF you must know:

You must understand all the following words: pure component, action creator, reducer, put, takeEvery, fromJS, ...

What is react-cmf

It's a framework. It is the results of the years of experience with react ecosystem at Talend. The goal is to provide one way to do the things keeping best pratices in mind.

Working with react-cmf

If you tried to work with the required addons listed above you will do some repetitive tasks and some boiler plate every time and on each components.

When working with a framework like angular you have the tools plus a guideline on how to use them. With CMF the idea is the same. Provide the good set of tools plus the guideline.

To start a project using react-cmf you can use bootstrap API.

Working with react-cmf means:

  • you write a set of configurable pure component connected using cmfConnect
  • you configure them using the settings
  • events are handled in a saga (effects are the way to write business code)

diagram rendering cycle

Side by side with angular 1:

  • components are React cmfConnected (pure) component
  • services are sagas
  • controllers are containers

UI sends actions into redux which are handled by sagas.

cmfConnect higher order component

cmfConnect create a component with all CMF features charged in it. Under the hood it uses the connect function and create a container.

Once your component is connected:

diagram cmfConnect

Read more about cmfConnect

Store structure

CMF uses react-redux store with the following structure

  • root
    • cmf
      • collections
      • components
      • settings

Collections and components use Immutable data structure.

ComponentState Management

Component state can be easily stored in cmf state, each are identified by their name and an unique key, so component state can be stored and reused later.

We give you the choice to use either:

  • CMF redux state (this.props.state && this.props.setState)
  • React component state (this.state && this.setState)

Warning: you should use the redux state except for part that require lots of mutation without sharing. For example for Forms you should prefer to use the internal React component state.

Collections management

Manage a local cache of your business data. You can connect your component to give it access to your data and being able to dispatch action to let CMF reducers write them.

You can dispatch some actionCreators in api.actions.collections for that.

Settings

We don't want to create a PR, merge, build to change a label of a button right? With CMF you can describe all your app just using json.

The json looks like this:

{
	"props": {
		"App#default": {
			"saga": "bootstrap"
		},
		"Navbar#default": {
			"brand": "Talend",
			"left": [{ "component": "Button", "componentId": "help" }]
		},
		"Button#help": {
			"id": "help",
			"label": "help",
			"payload": {
				"type": "MENU_HELP",
				"cmf": {
					"routerPush": "/help"
				}
			}
		}
	}
}

Scripts

When you have cmf in you project, it adds scripts in your node_modules/.bin

Tips you should add node_modules/bin folder into your path.

So you can use them either in CLI or in npm scripts.

Tests & mocks

When you are in the context of CMF and you want to test your component you will need to mock some stuff (context, ...).

We want testing experience to be easy so CMF provides some mocks for you.

import React from 'react';
import { Provider } from 'react-cmf/lib/mock';

import { render, screen } from '@testing-library/react';

import AppMenu from './AppMenu.component';

describe('AppMenu', () => {
	it('should render', () => {
		render(
			<Provider>
				<AppMenu />
			</Provider>,
		);
		expect(screen.getByRole('button')).toBeDefined();
	});
});

This way MyComponent may request for the following context:

  • registry
  • store

you may change the following using simple props:

  • store
  • state
  • registry

The http saga

The http saga is here to help execute some http requests from inside any saga.

By default, the credentials option of fetch is set to includes and not the default same-origin. It allows to share the credentials (cookies) in cross origin requests.

See credentials in the fetch() global function for more details.

More

Internals