Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
An assortment of common HTML form elements, editable in-line the React way.
Try out the demo and see what it looks like.
npm install riek --save-dev
or
yarn add riek --dev
Use --save-dev
because you don't want to build and pack JS/CSS in production
Import the library:
import { RIEToggle, RIEInput, RIETextArea, RIENumber, RIETags, RIESelect } from 'riek'
import _ from 'lodash'
Suppose we want to be able to edit title of a Task
and send changes to server. Here is a Task
stored flat inside of our parent React component:
this.state = {
id: 1,
title: 'Cover with tests',
completed: false
}
Now we need a function which will send the single altered { key: value }
and upsert local state. You can implement it inside of your flux/redux/mobx store:
const httpTaskCallback = (task) => {
request.post(`/api/task/${this.state.id}`)
.send(task)
.end((err, res) => {
if (!err) return this.setState({ ...task })
// Handle HTTP error
})
}
Meanwhile, there is a simple Express handler on our API server:
app.use('/api/task/:id', async (req, res) => {
// req.body will equal to { title: 'A new title' }
const { id } = req.params
await Task.update({ ...req.body }).where({ id })
res.send('OK')
})
Finally, in our render
method, we add a minimal RIEInput
:
<RIEInput
value={this.state.text}
change={this.httpTaskCallback}
propName='title'
validate={_.isString} />
...repeat the last step, adding a Riek component for any object property we wish to edit.
Components come unstyled, so take a look at demo.jsx for examples.
style
.<RIESelect ... options={[
{id: '1', text: 'one'},
{id: '2', text: 'two'},
{id: '3', text: 'three'}
]} />
The build process does not work with Node v6 at the moment: use Node Version Manager, or just plain Node v5.6.0.
npm i
npm run build
to compile the lib and demoindex.html
and check if it workslocalStorage.debug = '*'
to see debug messages, add more if necessaryFAQs
React Inline Edit Kit
We found that riek demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.